I made a code that lets you input numbers and only stop when you input zero and it adds every number that you input. I want to add another scanner input so that i can input the price per kilogram and then multiply it to the total weight when the loop is done but I can't figure out a way to do it. Please help me guys
This is my code:
int x = 0;
int sum = 0;
System.out.println("Enter the weight of rice per bag:");
System.out.print("Number: ");
Scanner keyboard = new Scanner(System.in);
x = keyboard.nextInt();
while (x != 0) {
sum = x + s