Define the method called getstringinput( ) using the method

Assignment Help Basic Computer Science
Reference no: EM13537722

For this assignment, you will be adding additional logic to handle a few additional properties of the order, the simple validation of properties, and the total cost of the order, including sales tax. You will implement these new capabilities using methods that you create.

1. Define the method called getStringInput( ) using the method header:

private static String getStringInput(String prompt)

This method must do the following:

Use JOptionPane.showInputDialog( ) to display the prompt.
Check the value that is returned.
If the value is null, the program should terminate.
If the value is a nonempty string, that string should be returned as the value of the method.
Otherwise, this request sequence should be repeated up to 3 times.
If the customer has not entered a valid input by then, the program should make an appropriate comment and then terminate.
2. Replace your existing code that requests the customer's name, return status, and color with calls to getStringInput( ).

3. Add a request for quantity, or the number of items that the customer wishes to order. Use getStringInput( ) to obtain this value from the customer. You will need to convert the quantity string into an int value. You should use the Integer.parseInt( ) method to accomplish this.

4. Create a method called totalCost( ) that calculates the total cost of an order. Use the following header:

private static double totalCost(int number, double cost, double salesTaxRate)

Number is the number of items (the quantity), cost is the unit cost (the cost of a single item), and salesTax is the sales tax rate. You should select a reasonable value for the unit cost (e.g., $10.00). You should select a reasonable value for the sales tax rate (e.g., 7%). Use your totalCost( ) method to calculate the total cost of the order.

Reference no: EM13537722

Questions Cloud

Calculate the magnitude of the charge of the particle : A positively charged particle of mass 6.00 10-8 kg is traveling due east with a speed of 80 m/s and enters a 0.42 T uniform magnetic field. What is the magnitude of the charge of the particle
Explain the bomb was immersed of water : A chemical engineer studying the properties of fuels placed 1.500 g of a hydrocarbon in the bomb of a calorimeter and filled it with O2 gas. The bomb was immersed in 2.500 L of water and the reaction initiated.
Implement a personal scheduler windows application : Implement a personal scheduler Windows application - Entries can be enabled and disabled: Enabled schedule entries appear dark in the main window, and disabled entries appear grayed out in the list.
Explain the type of equilibrium : When all of the products and reactants are gases, the type of equilibrium that will be established is a
Define the method called getstringinput( ) using the method : Define the method called getStringInput( ) using the method header
Explain reaction of iodine atoms to form i2 : For the reaction of iodine atoms to form I2, the experimental rate law is Rate = k[I]^2. What are the units for k if the unit of time is seconds
Find the electric field strengths at the cells surfaces : A study shows that mammalian red blood cells (RBCs) carry electric charge resulting from 4.4 million (rabbit cells) to 15 million (human cells) excess electrons spread over their surfaces
Compute how much work is done by the outside force : Equipotential surface A has a potential of 5650 V, while equipotential surface B has a potential of 7850 V. How much work is done by the outside force in moving the particle from A to B
Explain the initial amount of the reactant to be consumed : ^188 W decays by first order with a rate constant of 1.00 x 10^-2 d^-1. How long will it take for 93% of the initial amount of the reactant to be consumed

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Develop an i/o port decoder

Using a PLD, develop an I/O port decoder that generates the following high-bank I/O strobes: 300DH, 300BH, 00B6H, and 00EEH.

  Generate profits often referred to as creating

When the output of some units can be used as inputs to othe units, or if two organizations pools markets and expertise that results in lower costs and generate profits it is often referred to as creating?

  Sequence diagram for field officer

Draw a sequence diagram for the following use case. Draw only the first five messages sent. The FieldOfficer activates the "Report Emergency" function of her terminal. The system responds by presenting a form to the officer.

  Characterize a page fault rate using pure demand paging

Consider system which uses pure demand paging: When a process first start execution, how would you characterize a page fault rate?

  Demonstrate method polymorphism

Write some usable code snippets that demonstrate method polymorphism.

  What are some other uses for the break statement

How about using a break in a switch statement, show how you can really have a problem if you skip the break statement in a switch.

  Application development and programming languages

Compare and contrast object-oriented languages (Java, C++, C#, etc.) to imperative languages (C, Pascal, etc.) in terms of: Programmability, Maintainability, Performance, Development tools

  What is the total password population

A phonetic password generator picks two segments randomly for each six-letter password. the form of each segment is consonant, voul, consonant, where V= and C= (V)

  Explain roles and influences of computers

Topic is "The Global Economy" . You will be writing the term paper replying to the following questions? Explain the roles and influences of computers and communications technology in increase of trans-border economic activity.

  Computer program that inputs a degree

Write a computer program that inputs a degree of difficulty and seven judges' scores, and outputs the overall score for that dive. The program should ensure that all inputs are within the allowable data ranges

  Strong understanding of polymorphic variables

In a recent task that Sam had you complete, he noticed that you struggled with Polymorphic Variables. Just to make sure that you have a strong understanding of Polymorphic Variables

  Translate the first instruction into english

If the machine is started with its program counter containing 00, what bit pattern is in register 6 when the machine halts?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd