Basically I want to be able to input a number that isn't an option and then be given the option to choice again and get the statement to repeat.
Scanner keyboard = new Scanner(System.in);
double weight;
int Choice;
System.out.println("What is your weight in pounds?");
weight = keyboard.nextDouble();
System.out.println("Which planet would you like to see your weight on?\n 1. Venus 2. Mars 3. Jupiter\n 4. Saturn 5. Uranus 6. Neptune");
Choice =keyboard.nextInt();
if (Choice == 1){
System.out.println("Your weight on Venus would be " + (weight * 0.78));
}
else if (Choice == 2){
System.out.println("Your weight on Mars would be " + (weight * .39));
}
else if (Choice == 3){
System.out.println("Your weight on Jupiter would be " + (weight * 2.65));
}
else if (Choice == 4){
System.out.println("Your weight on Saturn would be " + (weight * 1.17));
}
else if (Choice == 5){
System.out.println("Your weight on Uranus would be" +(weight * 1.05));
}
else if (Choice == 6) {
System.out.println("Your weight on Neptune would be " + (weight * 1.23));
}
else
System.out.println("This was not a choice, try again!");
Choice = keyboard.nextInt();
}
This is an easier way to go, using a do-while loop and a switch.
Also fixed choice
Scanner keyboard = new Scanner(System.in);
double weight;
int choice;
System.out.println("What is your weight in pounds?");
weight = keyboard.nextDouble();
do {
System.out.println("Which planet would you like to see your weight on?\n 1. Venus 2. Mars 3. Jupiter\n 4. Saturn 5. Uranus 6. Neptune\n 7. Exit");
choice = keyboard.nextInt();
switch(choice) {
case 1:
System.out.println("Your weight on Venus would be " + (weight * 0.78));
break;
case 2:
System.out.println("Your weight on Mars would be " + (weight * .39));
break;
case 3:
System.out.println("Your weight on Jupiter would be " + (weight * 2.65));
break;
case 4:
System.out.println("Your weight on Saturn would be " + (weight * 1.17));
break;
case 5:
System.out.println("Your weight on Uranus would be" +(weight * 1.05));
break;
case 6:
System.out.println("Your weight on Neptune would be " + (weight * 1.23));
break;
case 7:
System.out.println("Bye");
break;
default:
System.out.println("This was not a choice, try again!");
break;
}
} while (choice != 7);
You have to learn the basic in programming language... do..while and switch statements.
Here is the sample program.
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
double weight;
int choice;
System.out.println("What is your weight in pounds?");
weight = keyboard.nextDouble();
do {
System.out
.println("Which planet would you like to see your weight on?\n 1. Venus 2. Mars 3. Jupiter\n 4. Saturn 5. Uranus 6. Neptune \n7.EXIT");
System.out.println();
choice = keyboard.nextInt();
switch (choice) {
case 1:
System.out.println("Your weight on Venus would be "
+ (weight * 0.78));
break;
case 2:
System.out.println("Your weight on Mars would be "
+ (weight * .39));
break;
case 3:
System.out.println("Your weight on Jupiter would be "
+ (weight * 2.65));
break;
case 4:
System.out.println("Your weight on Saturn would be "
+ (weight * 1.17));
break;
case 5:
System.out.println("Your weight on Uranus would be"
+ (weight * 1.05));
break;
case 6:
System.out.println("Your weight on Neptune would be "
+ (weight * 1.23));
case 7:
System.out.println("Leaving...");
break;
default:
System.out.println("This was not a choice, try again!");
break;
}
} while (choice != 7);
}
Use the Java Naming conventions to give names to variables. Start with lowercase letter.
This can be done with a while loop. Also consider using arrays.
String[] planets = {"Mars", "Jupiter", .... };
double[] factors = {0.45, 1.5, ....};
double mass = keyboard.nextDouble();
int choice = keyboard.nextInt();
while (choice < 0 || choice >= planets.length)
{
System.out.println("Not a valid option!");
choice = keyboard.nextInt();
}
double weight = mass * factors[choice];
System.out.println("Your weight on " + planets[choice] + " would be " + weight);
So, basically, you ask it once politely. Afterwards, start shouting that it is wrong, until the user gave a proper input.
Related
I'm making a vending machine program and I don't know how to use the users choice in my for loop because it gives me an error when i put choice in the loop.
public class PopGenerator {
double price[] = {2.49, 1.25, 3.49, 3.25, 2,25, 1.30, 3.40, 3.49, 2.50, 3.00};
public void beveragechoice()
{
Scanner c = new Scanner(System.in);
int choice = c.nextInt();
double price[] = {2.49, 1.25, 3.49, 3.25, 2.25, 1.30, 3.40, 3.49, 2.50, 3.00};
switch(choice)
{
case 1:
System.out.println("This beverage costs $" + price[0]);
break;
case 2:
System.out.println("This beverage costs $" + price[1]);
break;
case 3:
System.out.println("This beverage costs $" + price[2]);
break;
case 4:
System.out.println("This beverage costs $" + price[3]);
break;
case 5:
System.out.println("This beverage costs $" + price[4]);
break;
case 6:
System.out.println("This beverage costs $" + price[5]);
break;
case 7:
System.out.println("This beverage costs $" + price[6]);
break;
case 8:
System.out.println("This beverage costs $" + price[7]);
break;
case 9:
System.out.println("This beverage costs $" + price[8]);
break;
case 10:
System.out.println("This beverage costs $" + price[9]);
}
}
public void change()
{
System.out.println("Enter money put into the machine: ");
Scanner m = new Scanner(System.in);
int money = m.nextInt();
for(int x = choice; x >= 0 ; x--)
if (money == price[x])
{
System.out.println("No change.");
}
else
{
System.out.print("Your change is: ");
System.out.print(money - price[x]);
}
}
}
You can simplify both of your methods to avoid having multiple Scanners or pass variables through them, like this:
public void beveragechoice() {
double prices[] = {2.49, 1.25, 3.49, 3.25, 2,25, 1.30, 3.40, 3.49, 2.50, 3.00};
System.out.println("Select one beverage");
Scanner c = new Scanner(System.in);
int choice = c.nextInt();
if (choice > 0 && choice <= prices.length) {
double p = prices[choice - 1];
System.out.println("This beverage costs $" + p);
System.out.println("Enter money put into the machine: ");
double money = c.nextDouble();
if (money == p) {
System.out.println("No change.");
} else {
System.out.println("Your change is: $" + (money - p));
}
}
}
Hi guys i am having an issue with how to do this, i have googled it but its not making much sense.
i need to do this;
The program asks the user if they wish to continue.
If Yes is selected, it will return to the Main menu.
If No is selected, Total Amount Payable will be
displayed and then the program will terminate
int option, quantity, confirm;
float childTotal;
float adultTotal;
float seniorTotal;
final double childCost = 18;
final double adultCost = 36;
final double seniorCost = 32.50;
char resume;
Scanner input = new Scanner(System.in);
System.out.println("1 = Child (4-6 yrs)");
System.out.println("2 = Adult (16+ yrs)");
System.out.println("3 = Senior (60+ yrs)" + "\n");
System.out.println("Enter your option:" );
option=input.nextInt();
switch (option) {
case 1:
System.out.println("Enter total No of tickets for Child:" );
quantity=input.nextInt();
System.out.println("You are purchasing " + quantity + " child tickets");
System.out.println("Press 1 to confirm");
confirm=input.nextInt();
break;
case 2:
System.out.println("Enter total No of tickets for Adult:" );
quantity=input.nextInt();
System.out.println("You are purchasing " + quantity + " adult tickets");
System.out.println("Press 1 to confirm");
confirm=input.nextInt();
break;
default:
System.out.println("Enter total No of tickets for Senior:" );
quantity=input.nextInt();
System.out.println("You are purchasing " + quantity + " senior tickets");
System.out.println("Press 1 to confirm");
confirm=input.nextInt();
break;
}
if (confirm !=1) {
System.out.println("Incorrect key! User to go back to main menu");
}
System.out.println("Do you wish to continue? (Y/N) ");
resume = input.next().charAt(0);
if (resume == 'y' || resume == 'Y') {
} else {
switch (option) {
case 1:
childTotal=(int) ((double) quantity*childCost) ;
System.out.println("Total amount for child tickets: $" + childTotal);
break;
case 2:
adultTotal=(int) ((double) quantity*adultCost) ;
System.out.println("Total amount for adult tickets $" + adultTotal);
break;
default:
seniorTotal=(int) ((double) quantity*seniorCost);
System.out.println("Total amount for senior tickets $" + seniorTotal);
break;
}
}
Create a Boolean variable set as true.
boolean continueLoop = true;
Add your main logic into a while loop until continue is true
while(continueLoop){
//Do your code here
System.out.println("Do you wish to continue? (Y/N) ");
resume = input.next().charAt(0);
if (resume == 'y' || resume == 'Y'){}
else{
//Do Code here
continueLoop=false;
}
} //End while loop.
After the while loop continue with your code. I have changed the condition of resume == y to resume !=y because if the user does not press y the code should stop iterating.
Your code would become
int option, quantity, confirm;
float childTotal;
float adultTotal;
float seniorTotal;
final double childCost = 18;
final double adultCost = 36;
final double seniorCost = 32.50;
boolean continueLoop = true;
char resume;
Scanner input = new Scanner(System.in);
while(continueLoop){
System.out.println("1 = Child (4-6 yrs)");
System.out.println("2 = Adult (16+ yrs)");
System.out.println("3 = Senior (60+ yrs)" + "\n");
System.out.println("Enter your option:" );
option=input.nextInt();
switch (option) {
case 1:
System.out.println("Enter total No of tickets for Child:" );
quantity=input.nextInt();
System.out.println("You are purchasing " + quantity + " child tickets");
System.out.println("Press 1 to confirm");
confirm=input.nextInt();
break;
case 2:
System.out.println("Enter total No of tickets for Adult:" );
quantity=input.nextInt();
System.out.println("You are purchasing " + quantity + " adult tickets");
System.out.println("Press 1 to confirm");
confirm=input.nextInt();
break;
default:
System.out.println("Enter total No of tickets for Senior:" );
quantity=input.nextInt();
System.out.println("You are purchasing " + quantity + " senior tickets");
System.out.println("Press 1 to confirm");
confirm=input.nextInt();
break;
}
if (confirm !=1) {
System.out.println("Incorrect key! User to go back to main menu");
}
System.out.println("Do you wish to continue? (Y/N) ");
resume = input.next().charAt(0);
if (resume == 'y' || resume == 'Y') {
}else{
continueLoop = false;
switch (option) {
case 1:
childTotal=(int) ((double) quantity*childCost) ;
System.out.println("Total amount for child tickets: $" + childTotal);
break;
case 2:
adultTotal=(int) ((double) quantity*adultCost) ;
System.out.println("Total amount for adult tickets $" + adultTotal);
break;
default:
seniorTotal=(int) ((double) quantity*seniorCost);
System.out.println("Total amount for senior tickets $" + seniorTotal);
break;
}
}
}
}
I'm struggling to understand why intAt will not work in this program. The goal of program is to simply convert weights for a specific planet.
package weightonotherplanets;
import java.util.Scanner;
public class WeightonOtherPlanets
{
public static void main(String args[]){
System.out.println("What is your weight on the Earth?");
Scanner weightInput = new Scanner(System.in); // Enter your weight
int weight = weightInput.nextInt();
System.out.println("1. Voltar\n2. Krypton\n3. Fertos\n4. Servontos\n"); // Choice of planets
System.out.println(" Selection?");
Scanner selectionChoice = new Scanner(System.in);
int selection = selectionChoice.nextInt();
int select = selection.intAt(0); // This is the problem in the code
switch (select)
{
case '1':
System.out.println("Your weight on Voltor would be " + weight * 0.091);
break;
case '2':
System.out.println("Your weight on Krypton would be " + weight * 0.720);
break;
case '3':
System.out.println("Your weight on Fertos would be " + weight * 0.865);
break;
case '4':
System.out.println("Your weight on Servontos would be " + weight * 4.612);
break;
default:
System.out.println("Please make a selection.");
}
}
}
EDIT: I have some corrections as an answer. I needed to use another do-while loop for different scenarios in the slot machine. I have figured out the answer to this particular question and have posted the answer for anyone who would like to use this for help.
I have a single do while loop that will not finish. In order to enter the do while loop, I need to enter a number. It will not start unless the user enters something- it will give a mismatch error if one enters a letter which is understandable, but how can I get into the loop without the user entering anything?
Also, would putting in another do loop solve the problem of it not fully running? I'm confused as to the logic of it and my pseudocode is wrong. Thank you.
import java.util.Scanner;
import java.util.Random;
import java.io.*;
public class Slot2
{
public static void main(String[] args) throws IOException
{
int number;
System.out.println ("Welcome to the Slot Machine Simulator!");
System.out.println ("\nActions\n1. Start a new game\n2. Scores\n3. Exit");
System.out.print ("\nPlease select an action: ");
Scanner keyboard = new Scanner(System.in);
int option = keyboard.nextInt();
while (option != 1 && option != 2 && option != 3)
{
System.out.print ("\nThat is not an option. Please select an item number between 1-3: ");
option = keyboard.nextInt();
break;
}
if (option == 1)
{
String username;
double startingTotal = 100.0;
double userTotal = startingTotal;
System.out.print ("\nBefore the game begins, please enter your name: ");
username = keyboard.next( );
System.out.print ("\nGame start! You will begin with $100.00. Enter a negative value to quit the game. Good luck, " + username + "!");
do **//you have to enter a number here to get the 1st print statement,this is the error**
{
double bet = keyboard.nextDouble();
bet = 0.0;
userTotal = startingTotal - bet;
System.out.print ("You currently have: $%.2f" + startingTotal + "\nHow much would you like to bet?"); **//this is the part of the loop that works**
double winnings = 0.0;
double userFinalTotal = 0.0;
Random generator = new Random();
int slot1 = generator.nextInt(6);
int slot2 = generator.nextInt(6);
int slot3 = generator.nextInt(6);
String firstSlot = "";
switch (slot1)
{
case 0:
firstSlot = "Cherries";
break;
case 1:
firstSlot = "Oranges";
break;
case 2:
firstSlot = "Plums";
break;
case 3:
firstSlot = "Bells";
break;
case 4:
firstSlot = "Melons";
break;
case 5:
firstSlot = "Bars";
break;
}
String secondSlot = "";
switch (slot2)
{
case 0:
secondSlot = "Cherries";
break;
case 1:
secondSlot = "Oranges";
break;
case 2:
secondSlot = "Plums";
break;
case 3:
secondSlot = "Bells";
break;
case 4:
secondSlot = "Melons";
break;
case 5:
secondSlot = "Bars";
break;
}
String thirdSlot = "";
switch (slot3)
{
case 0:
thirdSlot = "Cherries";
break;
case 1:
thirdSlot = "Oranges";
break;
case 2:
thirdSlot = "Plums";
break;
case 3:
thirdSlot = "Bells";
break;
case 4:
thirdSlot = "Melons";
break;
case 5:
thirdSlot = "Bars";
break;
}
System.out.println ("-------------------------------");
System.out.println ("" + firstSlot + " " + secondSlot + " " + thirdSlot);
System.out.print ("-------------------------------");
if (slot1 == slot2 && slot1 == slot3)
{
winnings = bet * 3;
userFinalTotal = userTotal + winnings;
System.out.printf ("\nNumber of matches: 3. You win: $%.2f", winnings);
System.out.printf ("\nYou currently have: $%.2f", userFinalTotal);
}
else if ((slot1 == slot2 && slot2 != slot3) || (slot1 == slot3 && slot1 != slot2) || (slot2 == slot3 && slot3 != slot1))
{
winnings = bet * 2;
userFinalTotal = userTotal + winnings;
System.out.printf ("\nNumber of matches: 2. You win: $%.2f", winnings);
System.out.printf ("\nYou currently have: $%.2fn", userFinalTotal);
}
else
{
System.out.printf ("\nNumber of matches: 0. You win: $%.2f", winnings);
System.out.printf ("\nYou currently have: $%.2f", userFinalTotal);
}
if ((bet < 0) || (userFinalTotal <= 0))
{
break;
}
while (bet > userFinalTotal)
{
System.out.print("\nYour bet is greater than your current total. Please enter a valid amount: ");
bet = keyboard.nextDouble();
}
} while (userTotal > 0);
}
}
}
Try changing username = keyboard.next( ); to username = keyboard.nextLine( );, I am sure it will work.
There is nothing wrong with your do-while loop.
On top of that, you shouldn't declare these variables inside your while loop.
String username;
double startingTotal = 100.0;
double userTotal = startingTotal;
I have a printwriter statement in a do-while loop in order to print the scores of every user that plays the slot machine. However, I think because of this scores print multiple times when it says to view scores (option 2). Is this because of the variable used, or the fact it is in a do-while loop?
import java.util.Scanner;
import java.util.Random;
import java.io.*;
public class Slot3
{
public static void main(String[] args) throws IOException
{
System.out.println ("Welcome to the Slot Machine Simulator!");
int option = 0;
//if the user selects a 1 or 2 (does not want to exit) then this loop will run
do
{
System.out.println ("\nActions\n1. Start a new game\n2. Scores\n3. Exit");
System.out.print ("\nPlease select an action: ");
Scanner keyboard = new Scanner(System.in);
option = keyboard.nextInt();
keyboard.nextLine();
while (option != 1 && option != 2 && option != 3)
{
System.out.print ("\nThat is not an option. Please select an item number between 1-3: ");
option = keyboard.nextInt();
keyboard.nextLine();
}
//this will occur if the user selects 1 to play the game
if (option == 1)
{
double money = 100.00;
double bet = 0.00;
double winnings = 0.00;
double score = 0.00;
int count = 0;
System.out.print ("\nBefore the game begins, please enter your name: ");
String username = keyboard.nextLine();
System.out.print ("\nGame start! You will begin with $100.00. Enter a negative value to quit the game. Good luck, " + username + "!");
System.out.printf("\nYou currently have $%.2f.", 100.00);
do
{
System.out.printf("\n\nHow much would you like to bet? ");
bet = keyboard.nextDouble();
if ((bet < 0) || (money <= 0))
{
break;
}
while (bet > money)
{
System.out.print("\nYour bet is greater than your current total. Please enter a valid amount: ");
bet = keyboard.nextDouble();
}
//create random numbers
Random generator = new Random();
int slot1 = generator.nextInt(6);
int slot2 = generator.nextInt(6);
int slot3 = generator.nextInt(6);
String firstSlot = "";
switch (slot1)
{
case 0:
firstSlot = "Cherries";
break;
case 1:
firstSlot = "Oranges";
break;
case 2:
firstSlot = "Plums";
break;
case 3:
firstSlot = "Bells";
break;
case 4:
firstSlot = "Melons";
break;
case 5:
firstSlot = "Bars";
break;
}
String secondSlot = "";
switch (slot2)
{
case 0:
secondSlot = "Cherries";
break;
case 1:
secondSlot = "Oranges";
break;
case 2:
secondSlot = "Plums";
break;
case 3:
secondSlot = "Bells";
break;
case 4:
secondSlot = "Melons";
break;
case 5:
secondSlot = "Bars";
break;
}
String thirdSlot = "";
switch (slot3)
{
case 0:
thirdSlot = "Cherries";
break;
case 1:
thirdSlot = "Oranges";
break;
case 2:
thirdSlot = "Plums";
break;
case 3:
thirdSlot = "Bells";
break;
case 4:
thirdSlot = "Melons";
break;
case 5:
thirdSlot = "Bars";
break;
}
System.out.println ("\n-------------------------------");
System.out.printf ("%-12s%-10s%5s\n", firstSlot , secondSlot , thirdSlot);
System.out.print ("\n-------------------------------");
//check how many of the slots match to calculate the winnings
if (slot1 == slot2 && slot1 == slot3)
{
winnings = bet * 3;
money -= bet;
score = money + winnings;
System.out.printf ("\nNumber of matches: 3. You win: $%.2f", winnings);
System.out.printf("\nYou currently have: $%.2f", score);
}
else if ((slot1 == slot2 && slot2 != slot3) || (slot1 == slot3 && slot1 != slot2) || (slot2 == slot3 && slot3 != slot1))
{
winnings = bet * 2;
money -= bet;
score = money + winnings;
System.out.printf ("\nNumber of matches: 2. You win: $%.2f", winnings);
System.out.printf("\nYou currently have: $%.2f", score);
}
else
{
winnings = bet * 0;
money -= bet;
score = money + winnings;
System.out.printf ("\nNumber of matches: 0. You win: $%.2f", winnings);
System.out.printf("\nYou currently have: $%.2f", score);
}
} while ((bet > 0) && (money > 0));
FileWriter fwriter = new FileWriter("scores.txt", true);
PrintWriter outputWriter = new PrintWriter(fwriter);
outputWriter.printf("\n\n%1s%15s" , "Name" , "Score");
outputWriter.printf ("\n\n%1s%15s" , "----" , "-----");
outputWriter.printf ("\n\n%1s%15s" , username , score);
outputWriter.close();
System.out.println("\n\nGame over! Your score has been written to scores.txt, " + username + "!");
} //end of actions for select option 1
//option 2 user wants to read their scores
if (option == 2)
{
File myFile = new File("scores.txt");
//if there are no scores to read
if (!myFile.exists())
{
System.out.println("There are no scores to display at this time.");
continue;
}
File file = new File("scores.txt");
Scanner inputFile = new Scanner(file);
while (inputFile.hasNext())
{
String username = inputFile.nextLine();
System.out.println(username);
}
inputFile.close();
} //close option 2
} while (option != 3); //close 1st do-while loop
if (option == 3)
{
System.out.print ("\nGoodbye!");
System.exit(0);
}
}
}
Int counter = 0, input = 0;
While(counter < 10 && input = 0)
{
Thread.sleep(1000);
Counter++;
input = Scan.nextInt()
}
Not the greatest code I did this from my phone so
I want to use switch statement after an if statement but I can't and I don't know what is the problem.
public class main {
public static void main (String[] args) {
String input; //To hold user's input.
char selectPackage; //To hold Internet Package
double hourUsage, totalCharges, addCharges; //other variables
//Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
//Prompt the user to select a Internet Package.
System.out.print("Which package did you purchase? ( Enter the Package's letter)");
input = keyboard.nextLine();
selectPackage = input.charAt(0);
System.out.print("Please select the amount of hours used.");
input = keyboard.nextLine();
hourUsage = Double.parseDouble(input);
//Display pricing for selected package...
switch (selectPackage)
{
case 'a':
case 'A':
if (hourUsage > 10)
{
addCharges = hourUsage - 10;
totalCharges = (addCharges * 2.0) + 9.95;
System.out.println("You have used " + hourUsage + " hours and your total is $" +
totalCharges + " per month. ");
}
else
System.out.println("Your total is $9.95 per month.");
break;
case 'b':
case 'B':
if (hourUsage > 20 )
{
addCharges = hourUsage - 20;
totalCharges = (addCharges * 1.0) + 13.95;
System.out.println("You have used " + hourUsage + " and your total is $" + totalCharges + " per month.");
}
else
System.out.println("Your total is $13.95 per month.");
break;
case 'c':
case 'C':
System.out.println("Your total is $19.95 per month.");
break;
default:
System.out.println("Invalid Choice. Choice A,B,C");
}
}
}
System.out.println("Your total is $19.95 per month.");
}
else
System.out.println("Your total is $19.95 per month.");
}
}
Now I want to use the switch statement for telling user that if he/she chose package "B", he would save 20 dollars.
I have had a look through your code and have made ALOT of edits and improvements, the main issue I found was your use of } in the wrong places. I believe this was because you haven't organised your code very well; in future consider organising your code to make it easier to find errors, below I have corrected your code and have put the last few lines into a comment as I'm not sure why you have them there, if there are any questions about it, just ask me:
public class Test {
public static void main(String[] args) {
char selectPackage; //To hold Internet Package
double hourUsage, totalCharges, addCharges; //other variables
//Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
//Prompt the user to select a Internet Package.
System.out.print("Which package did you purchase? ( Enter the Package's letter)");
char input = keyboard.next().charAt(0);
selectPackage = Character.toUpperCase(input);
System.out.print("Please select the amount of hours used.");
hourUsage = keyboard.nextDouble();
//Display pricing for selected package...
switch (selectPackage) {
case 'A':
if (hourUsage > 10) {
addCharges = hourUsage - 10;
totalCharges = (addCharges * 2.0) + 9.95;
System.out.println("You have used " + hourUsage + " hours and your total is $" + totalCharges + " per month. ");
}
else {
System.out.println("Your total is $9.95 per month.");
}
break;
case 'B':
if (hourUsage > 20 ) {
addCharges = hourUsage - 20;
totalCharges = (addCharges * 1.0) + 13.95;
System.out.println("You have used " + hourUsage + " and your total is $" + totalCharges + " per month.");
}
else{
System.out.println("Your total is $13.95 per month.");
}
break;
case 'C':
System.out.println("Your total is $19.95 per month.");
break;
default:
System.out.println("Invalid Choice. Choice A,B,C");
}
/**System.out.println("Your total is $19.95 per month.");
System.out.println("Your total is $19.95 per month.");
**/
}
}