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);
}
}
Brandon, There is no sentinel loop. In my point of view, this is the program that you want,
import java.util.*;
public class Stack3{
public static void main(String []args){
int count=0;
int days;
double DailyFee=0, NontaxTotal, CarType, Total,FullTotal=0;
Scanner in=new Scanner(System.in);
System.out.println("If there are any customer press 1 else press 0");
int cus=in.nextInt();
// this is sentinel loop
while(cus!=0){
count++;
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 = in.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 = in.nextInt();
double x=days;
NontaxTotal = (DailyFee * x);
Total = (NontaxTotal * 1.06);
FullTotal+=Total;
//included 2 decimals only
System.out.printf("The total amount due is $ %.2f \n",Total);
System.out.println("If there are any customer press 1 else press 0");
cus=in.nextInt();
}
System.out.println("Count of customers :- "+count);
System.out.printf("Total of the Day :- %.2f",FullTotal);
}
}