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

  What influence the concept of pervasive computing

What you believe the eventually influence will be of concept of "pervasive computing" or"location based services" will be on society.

  Sketch hierarchy chart and draw logic for program

Sketch the hierarchy chart and draw the logic for program which comprises housekeeping, detail loop and end-of-job modules and which computes service charge customers.

  Create a java gui business application

Create a Java GUI business application. This program may be any business application of your choice.

  Derive the simplest product-of-sums expression

Derive the simplest product-of-sums expression for the function f(x1,x2,x3,x4)= (x1'+x3'+x4')(x2'+x3'+x4)(x1+x2'+x3') HINT: use consensus property.

  Store configuration information on motherboard in cmos

Why do you believe the trend is to store configuration information on the motherboard in CMOS setup rather than by using jumpers or switches?

  Write a program in c++ for a server

Write a program in C++ for a server (called math solver) which solves three math problems: factorial (i.e. n!), exponent with base 2 (i.e. 2n), and cube (i.e. n3).

  How to hack the most common web browser

Discuss and explain how to hack the most common Web browser. Also include methods for securing Web browsers. Include at least two different Web browsers in your discussion.

  Explain change like that for business purposes

This adaptation of gaming by seniors was due in large part to ease of use. The Wii controller changed everything. Take a look at the news article and imagine a change like that for business purposes. Will it happen?

  What are the major obstacles in moving this forward

These are called code generators. Analyze the advantages and disadvantages of this trend. What are the major obstacles in moving this forward?

  How many register window should be saved to memory as result

Assume two more calls are made after the maximum value from part (a) is reached. How many register windows must be saved to memory as a result?

  Calculate population increase

The output then would be that count. You will want to use 2 variables, one for the index of the for loop ( and the counter in the do loop) and the other variable to keep track of your "current" population.

  List the three actions we could take upon receiving a signal

list three disadvantages for using signals as a means of interprocess comm.

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