February 8th, 2011, 06:43 AM
A program is needed that requests from the end-user the subtotal and gratuity rate, and then computes the gratuity and total, and displays to the end-user the subtotal, gratuity amount and the total amount. The Output must be labeled
Some processing requirements:
name the program - Gratuity.java
initialize all variables
Use the Scanner class to accept the input
Use the System Class to display the output
you will prompt the end user for the bill amount
you will prompt the end user for the gratuity rate
be sure to specify to the user how to enter in the gratuity amount either has a decimal or whole number. Because it will make a difference when calculating for example let's say you assume (and you know what they say about that...) the user will enter in the value in a decimal format; .20 but they enter in 20 that gives the server a great tip! But what about the other way, your program expects a whole number and you enter in a decimal - almost stiffing the server!
comment the top of your program will the following:
/* Program Name:
I am not Sure if this is right can someone please help
Prompt for subtotal_cost
Read subtotal_cost value
Calculate the total_due
Print "Subtotal Cost:" subtotal_cost
Print "Gratuity Cost:" gratuity_cost
Print "The Total Amount Due is" total_duesure if this will be acceptable or is correct;
Any help will gladly be appreciated.
February 8th, 2011, 06:11 PM
Re: First Program
Looks like fine pseudo code. I think you should print something about how the user should input the gratuity rate (whole number or decimal (ex: 15 or .15)), and then you need to prompt the user to enter the gratuity rate and read that value in. The assignment is leaving the gratuity amount up to the user and the way you have it, 15% is hard-coded in.
So I would add:
Print "Please enter the gratuity rate as a decimal"
Prompt for gratuity_rate
Read gratuity_rate value
and replace 15% with gratuity_rate
and then of course write Java code for your pseudo code
February 15th, 2011, 07:41 PM
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.