samedi 27 octobre 2018

Q : Rental Car Calculator | Use a sentinel value loop

I am confused on if I am following this right and was kind of looking for reassurance along with some help. So my main question is am I following my instructor question is: when he says build it using a sentinel value loop?

Secondly, how can I round the Total to only two decimals?

if it helps my assignment is this:

Instructions: Use a sentinel value loop.

Ask each user for:

Type of vehicle (May use something other than strings, such as: 1 for economy, 2 for sedan, etc.) Days rented Calculate the (For each customer):

Rental cost, Taxes, Total Due. There are three different rental options with separate rates: Economy @ 31.76, sedan @ 40.32, SUV @ 47.56. [Note: only whole day units to be considered (no hourly rates)].

Sales tax is = to 6% on the TOTAL.

Create summary data with:

Number of customers Total money collected. Also, Include IPO, algorithm, and desk check values (design documents).

{MY DESIGN & PROGRESS}

package yipe;

import java.util.*; import java.lang.Math;

public class Umm {

int count = 0;
static int days;
static double DailyFee, NontaxTotal, CarType, Total;



public static void main(String[] args) {

    Scanner keyboard = new Scanner(System.in);

    System.out.print("What vehical would you like to rent?\n");
    System.out.println("Enter 1 for an economy car\n");
    System.out.println("Enter 2 for a sedan car\n");
    System.out.println("Enter 3 for an SUV");
    CarType = keyboard.nextInt();
    if (CarType == 1)
          DailyFee=31.76;
        else if(CarType == 2)
          DailyFee=40.32;
        else if(CarType == 3)
          DailyFee=43.50;

    System.out.print("Please enter the number of days rented. (Example; 3) : ");
    days = keyboard.nextInt();

    NontaxTotal = (DailyFee * days);
    Total = (NontaxTotal * 1.06);







    System.out.printf("The total amount due is $" + Total);

}

}

Aucun commentaire:

Enregistrer un commentaire