Define method get string input

Assignment Help C/C++ Programming
Reference no: EM13763345

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 ***** 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.

5. Enhance your confirmation dialog so that it displays the entire order, including the name, the color, the quantity, and the total cost.

Reference no: EM13763345

Questions Cloud

Security models and cloud operations : From the first e-Activity, analyze the industry researched for each security model would be most applicable, and explain why you believe that to be the case. Identify the security models from your findings.
What policy would you recommend an employer adopt : What policy would you recommend an employer adopt regarding use of criminal history in hiring decisions? Why? Would the policy differ according to the type of job in question, or the nature of the conviction? If so, how
Complete the code found in player.java : You are to complete the code found in Player.java. Once completed you can then simulate a good old game of Rock, Paper, Scissors. To play you need to compile Player.java, InputMaker.java, and RockPaperScissorsTest.java. Then you will run InputMake..
Pension expense-journal entries : Ultra-Home Corporation provides the following information related to its defined-benefit pension plan for 2014.
Define method get string input : 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..
Define and discuss cost of goods sold : 1. What does the current ratio reveal about a company's financial condition? 2. Define and discuss Cost of Goods sold.
Write three hundred words essay about the commercialization : Write a 300 words essay about the commercialization. Describe your position on commercialization about the media and defend your position (use examples).
Self-sufficient and avoid all the hassles of city life : Why do cities exist? Why don't we all just live on large lots of land in Texas/rural Ontario/etc? We could be self-sufficient and avoid all the hassles of city life.
Differences between traditional and derivative instruments : What are the differences between traditional and derivative instruments? Why do companies use derivative instruments? Are derivatives a good investment? Explain why or why not.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Design an algorithm to find the selling price

To make a profit, the prices of the items sold in a furniture store are marked up by 60%. Design an algorithm to find the selling price of an item sold at the furniture store. What information do you need to find the selling price?

  Create a function in c++ that subtracts two vectors

Create a function in c++ that subtracts two vectors. The function returns a vector than can also be negative.

  Credit card is mastercard or visa card

Write  a C++ program  that  reads  the  card  type  and  the  card  number  and  then determine  if  the  card number entered is a valid card number

  Describe the chemical symbol of one of the elements

Write a program that reads a single character describing the chemical symbol of one of the elements H, C, N, O, F and prints the full name of the element.

  Sockets for this problem you will implement a client-server

sockets for this problem you will implement a client-server version of the rock-paper-scissors-lizard-spock game which

  Show that regularity is preserved under the shift operation

Show that the regularity is preserved under the shift operation - I have the answer already but i do not understand

  Write a number guessing game in which the computer selects

Write a number guessing game in which the computer selects a random number in the range of 0 to 100, and users get a maximum of 20 attempts to guess it.

  State a program that reads an integer from the keyboard

Write a program that reads an integer from the keyboard, and prints the integer to the screen. You must write a function to do this task. After the integer is printed, you must call a function (that you write) which asks the user to enter a ‘Y' or..

  Rationalnumber class a rational number is a number that can

rationalnumber class a rational number is a number that can be represented as the quotient of two nbspintegers. for

  Define program testing & documentation

Devise a test plan carefully, making sure that the purpose of the particular test is clearly stated, the data for each test is specified (that is, any inputs expected from the user or the programmer), and a description of the expected result from ..

  Using opengl to create a cube

Write a program in C/C++ using OpenGL to create (without using built in function) a cube by implementing translation algorithm by translating along 1. X-axis, 2.Y-axis and 3. X and Y plane

  Write a c++ program to calculate the gpa of 5 courses

Write a C++ program to calculate the Gpa of 5 courses. When users enter the grades and credits of the courses from the keyboard

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