First Program
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: First Program

  1. #1
    Join Date
    Feb 2011

    First Program

    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 -
    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
    gratuity_cost=subtotal_cost *15%
    total_due=subtotal_cost+ gratuity_cost
    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.

  2. #2
    Join Date
    Feb 2011

    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

  3. #3
    Join Date
    Feb 2011

    Re: First Program

    Thank you so Much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)