2.Learning Objectives
Design and write pseudocode using a repetition structure
Design and write Java for a class, including attributes, accessors, mutators, and
...
va for a class, including attributes, accessors, mutators, and constructors.
Design and write Java for an application program that instantiates and uses objects of a user-defined class.
Use the repetition structure in class methods and application program modules.
Perform error checking.
Use a graphical drawing program (ArgoUML) to create class diagrams.
Directions for completing and submitting the homework:
You will be submitting the following files:
Task #1:
Pseudocode written with Word, Notepad++, or similar application
Task #2:
Pennies.java
Task #3
Inventory.java
The application class created in 3b below
The UML class diagram created in ArgoUML, Raptor, or similar application
Homework Assignment:
Write the pseudocode needed to complete Chapter 5, number 9 – Pennies for Pay.
Implement Pennies for Pay in Java.
The Secondhand Rose Resale Shop is having a seven-day sale during which the price of any unsold item drops 10 percent each day. Design a class diagram showing the class, the application program, the relationship between the two, and multiplicity. Then write the Java code as described below. Be sure to follow the CSI 117 Style Criteria (Links to an external site.) for naming conventions, class diagrams, pseudocode, keywords, and operators.
An Inventory class that contains:
an item number and the original price of the item. Include the following:
A default constructor that initializes each attribute to some reasonable default value for a non-existent inventory item.
Another constructor method that has a parameter for each data member, called the overloaded constructor. This constructor initializes each attribute to the value provided when an object of this type is instantiated. Be sure to incorporate adequate error checking for all numeric attributes.
Accessor and mutator methods for each attribute. Be sure to incorporate adequate error checking for all numeric attributes.
Extra credit for including Javadoc comments.
An application program that contains two methods: the main() module and the printSaleData()module.
The main()module must do the following:
create an Inventory object using the default constructor
use a loop to get inventory items from the user. The user should enter the item number and the original price of the item. This loop should continue until the user indicates that they have no more items to enter. For each item entered by the user, the code inside the loop should do the following 2 items:
set the attributes of the Inventory object by calling the appropriate method in the Inventory class for each item entered by the user
send the Inventory items, one at a time, to the printSaleData() module for processing
Extra credit for including Javadoc comments.
The printSaleData()module must accept an Inventory object and produce a report that shows the item number and the price of an inventory item on each day of the sale, one through seven, using a loop. For example, an item with an original price of $10.00 costs 10 percent less, or $9.00, on the first day of the sale. On the second day of the sale, the same item is 10 percent less than $9.00, or $8.10.
View More
3. When to balance dice are rolled, there are 36 possible outcomes. Find the probability that the sum is
...
is a multiple of three or greater than eight.
A certain game consist of rolling a single fair die and pays off as follows nine dollars for a six, six dollars for a five, one dollar for four and no payoffs otherwise.Find the expected winnings for this game.
A fair die is rolled four times. A 6 is considered success While all other outcomes are failures find the probability of three successes.
A pet store has nine puppies including 4 poodles 3 terriers and 2 retrievers. If Rebecca an errand in that order each select one puppy at random without replacement find the probability that Aaron select a retriever given that from last Rebecca selects a poodle.
Experience shows that a ski lodge will be for (166 guests) if there is a heavy snowfall in December, well only partially full (52 guests) With a light snowfall. What is the expected number of guests if the probability for a heavy snowfall is 0.40? I assume that heavy snowfall and light snowfall are the only two possibilities.
A pet store has six puppies Including two poodles two Terriers and to retrievers. If Rebecca and Aaron in that order each select one puppy random with replacement (They both may select the same one) Find the probability That Rebecca selects a terrier and Aaron selects a retriever.
Three married couples arrange themselves randomly in six consecutive seats in a row. Determine (A) the number of ways the following event can occur, And (B) the probability of the event. (The denominator of the probability fraction will be 6!=720, The total number of ways to arrange six items ). Each man was that immediately to the right of his wife.
A coin is tossed five times. Find the probability that all our heads. Find the probability that at least three are heads.
A certain prescription drug is known to produce undesirable facts and 35% of all patients due to drug. Among a random sample of a patient using a drug find the probability of the stated event. Exactly 5 have undesired effects.
10,000 raffle tickets are sold. One first prize of 1600, for second prizes of 800 each, And 9/3 prizes of 300 each or to be awarded with all winners selected randomly. If you purchase one ticket what are your expected winnings.
Suppose a charitable organization decides to Raise money by raffling A trip worth 500. If 3000 tickets are sold at one dollar each find the expected net winnings for a person who buys one ticket. Round to the nearest cent
Three men and seven women are waiting to be interviewed for jobs. If they are selected in random order find the probability that all men will be interviewed first
A fair diet is rolled. What is the probability of rolling on our number or a number less than three.
The pet store has 15 puppies, including five poodles, five Terriers, and five retrievers. If Rebecca and Aaron, in that order, select one puppy at random without replacement, find the probability that both select a poodle
Beth is taking a nine question multiple-choice test for which each question Has three answer choices, only one of which is correct. Beth decides on answering By rolling a fair die And making the first answer choice if the die shows one or two, The second If the die shows three or four, and the third if the die shows five or six. Find the probability of the stated event. Exactly 6 correct answers
For the experiment of drawing a single card from a standard 52 card deck find (a) the probability and (b) the odds are in favor that they do not drive six
View More