I have been looking at this for hours and cannot figure out why it will not show the subtotal. PLEASE HELP:
Code:
import java.io.*;
import java.util.*;
public class CS0401JNRV2
{
//Constants For Program--------------
//GASOLINE CONSTANTS
static double REGULAR = 3.75,
PLUS = 4.00;
//PROPANE CONSTANTS
static double WITHEXCHANGE = 20.00,
WITHOUTEXCHANGE = 35.00;
//BURRITO CONSTANTS
static double FIRSTFIVE = 1.00,
NEXTFIVE = 0.90,
ADDITIONAL = 0.80;
//VANTAGE CARD BENEFITS
static double V_GASDISCOUNT = 0.10,
V_PROPANEDISCOUNT = 0.10,
V_FIRSTFIVE = 0.90,
V_NEXTFIVE = 0.80,
V_ADDITIONAL = 0.70;
//-----------------------------------
public static void main(String[]args)
{
Scanner keyboard = new Scanner(System.in);
//Totals For User--------------------
//GASOLINE INFO
int typeOfGas = 0;
double numOfGallons = 0;
//PROPANE INFO
int numOfTanks = 0,
numOfReturning = 0;
//BURRITO INFO
int numOfBurrito = 0;
//-----------------------------------
//General Info-----------------------
boolean vantageCard = false,
ifCustomer = false,
exitCMD = false;
double vantageCardBal = 0;
while (exitCMD == false)
{
System.out.println("Welcome to Gas, Gas, and Gas!");
getCustomer(ifCustomer, keyboard);
getVantageCard(vantageCard, keyboard, vantageCardBal);
getChoice(keyboard, typeOfGas, numOfGallons, numOfTanks, numOfReturning, numOfBurrito, vantageCard);
}
}
public static void getCustomer(boolean ifCustomer, Scanner keyboard)
{
int userInput;
while (ifCustomer == false)
{
System.out.print("Is there a customer in line? (1 = yes, !1 = no) > ");
userInput = keyboard.nextInt();
if (userInput == 1)
{
ifCustomer = true;
}
else
ifCustomer = false;
}
}
public static void getVantageCard(boolean vantageCard, Scanner keyboard, double vantageCardBal)
{
int userInput = 0;
vantageCardBal = 0;
while (userInput < 1 || userInput > 2)
{
System.out.print("Are you a GasVantage card member? (1 = yes, 2 = no) > ");
userInput = keyboard.nextInt();
}
if (userInput == 1)
{
vantageCard = true;
System.out.print("Welcome back, GasVantage Customer!" +
"\nWhat is your current GasVantage balance? > ");
vantageCardBal = keyboard.nextDouble();
System.out.print("You will receive: " +
"\n\t\t$0.30/gal. reg., $3.70 gal. plus" +
"\n\t\t10.0% off your propane tanks" +
"\n\t\t$0.10/ea discount on burritos\n");
}
else if (userInput == 2)
{
vantageCard = false;
}
}
//Asks user what they would like to choose from a selection of, gasoline, propane, checkhout, and
public static void getChoice(Scanner keyboard, int typeOfGas, double numOfGallons, int numOfTanks, int numOfReturning, int numOfBurrito, boolean vantageCard)
{
int userInput = 1;
boolean exitLoop = false;
while (exitLoop == false)
{
if (vantageCard == true)
{
System.out.println("Here are your options:\n" +
"\t\t1) Buy Gasoline: $3.45/gal. reg., $3.70/gal. plus\n" +
"\t\t2) Buy Propane:\n" +
"\t\t\t(with return tank): $18.00/20 lb tank\n" +
"\t\t\t(no tank): $31.50/20 lb tank\n" +
"\t\t3) Buy Burritos: $0.90/each [with volume discounts]\n" +
"\t\t4) Check out\n" +
"Note: For options 1-3, selecting more than once will overwrite previous selections");
}
else
{
System.out.println("Here are your options:\n" +
"\t\t1) Buy Gasoline: $3.75/gal. reg., $4.00/gal. plus\n" +
"\t\t2) Buy Propane:\n" +
"\t\t\t(with return tank): $20.00/20 lb tank\n" +
"\t\t\t(no tank): $35.00/20 lb tank\n" +
"\t\t3) Buy Burritos: $1.00/each [with volume discounts]\n" +
"\t\t4) Check out\n" +
"Note: For options 1-3, selecting more than once will overwrite previous selections");
}
System.out.print("What is your choice? > ");
userInput = keyboard.nextInt();
if (userInput == 1)
{
getGasoline(keyboard, typeOfGas, numOfGallons);
}
else if (userInput == 2)
{
getPropane(keyboard, numOfTanks, numOfReturning);
}
else if (userInput == 3)
{
getBurrito(keyboard, numOfBurrito);
}
else if (userInput == 4)
{
getSubtotal(typeOfGas, numOfGallons, numOfTanks, numOfReturning, numOfBurrito, vantageCard);
exitLoop = true;
}
}
}
//Asks the user what type of gas they would like and how many gallons of it they want.
public static void getGasoline(Scanner keyboard, int typeOfGas, double numOfGallons)
{
typeOfGas = 0;
numOfGallons = 0;
while (typeOfGas < 1 || typeOfGas > 2)
{
System.out.print("Do you want: " +
"\n\t1) Regular Gasoline" +
"\n\t2) Plus Gasoline" +
"\n> ");
typeOfGas = keyboard.nextInt();
}
while (numOfGallons <= 0)
{
System.out.println("How many gallons do you want? > ");
numOfGallons = keyboard.nextDouble();
}
}
//Asks the user how many propane tanks they would like
public static void getPropane(Scanner keyboard, int numOfTanks, int numOfReturning)
{
numOfTanks = 0;
numOfReturning = 0;
while (numOfTanks <= 0)
{
System.out.println("How many propane tanks do you want? > ");
numOfTanks = keyboard.nextInt();
}
while (numOfReturning > numOfTanks)
{
System.out.println("How many tanks are you returning? (<= " + numOfTanks + ") > ");
numOfReturning = keyboard.nextInt();
if (numOfReturning < 0)
{
System.out.println("Invalid number -- 0 tanks returned");
numOfTanks = 0;
numOfReturning = 0;
break;
}
}
}
//Asks the user how many burritos the customer would like
public static void getBurrito(Scanner keyboard, int numOfBurrito)
{
while (numOfBurrito <= 0)
{
System.out.println("How many burritos do you want? > ");
numOfBurrito = keyboard.nextInt();
}
}
public static void getSubtotal(int typeOfGas, double numOfGallons, int numOfTanks, int numOfReturning, int numOfBurrito, boolean vantageCard)
{
System.out.print("Here is your subtotal:");
//Gas Calculations
if (vantageCard == true)
{
if (typeOfGas == 1)
{
System.out.println("Gasoline: " + numOfGallons + " at " + (REGULAR - V_GASDISCOUNT) + " per gallon:\t\t" + (numOfGallons * (REGULAR - V_GASDISCOUNT)));
}
else if (typeOfGas == 2)
{
System.out.println("Gasoline: " + numOfGallons + " at " + (PLUS - V_GASDISCOUNT) + "per gallon:\t\t" + (numOfGallons * (PLUS - V_GASDISCOUNT)));
}
}
else if (vantageCard == false)
{
if (typeOfGas == 1)
{
}
else if (typeOfGas == 2)
{
}
}
}
}