This is the code I made for equating the change due. It's probably all wrong. When I go to run it, all three user inputs (Enter money given, enter amount, enter taxrate) are there. The one my teacher did shows the first one and he would enter an amount and once he pressed enter, showed the second one. How do I do this?
package change;
import java.util.*;
public class Change
{
public static void main (String [] args)
{
Scanner in = new Scanner(System.in);
//user input
System.out.print("Enter money given: ");
System.out.print("Enter amount: ");
System.out.print("Enter taxrate in percent: ");
//variables
double amtGiven = in.nextDouble();
double amt = in.nextDouble();
double taxrate = in.nextDouble();
double tax = in.nextDouble();
double totalamt = in.nextDouble();
double changedue = in.nextDouble();
//equation
tax = (taxrate/100) * amt;
totalamt = tax + amt;
changedue = amtGiven - totalamt;
}
}
package change;
import java.util.*;
public class Change
{
public static void main (String [] args)
{
Scanner in = new Scanner(System.in);
//user input
System.out.print("Enter money given: ");
System.out.print("Enter amount: ");
System.out.print("Enter taxrate in percent: ");
//variables
double amtGiven = in.nextDouble();
double amt = in.nextDouble();
double taxrate = in.nextDouble();
double tax = in.nextDouble();
double totalamt = in.nextDouble();
double changedue = in.nextDouble();
//equation
tax = (taxrate/100) * amt;
totalamt = tax + amt;
changedue = amtGiven - totalamt;
}
}