I’m trying to make a calculator that takes a number from the user then multiplies it I set but I’ve run into a roadblock. I need have my code take the product at the end of each step then multiply it by the numbers I set but I can’t figure out how to do that. All I’ve managed to do so far is multiply the user’s number at each step which isn’t what I need to do.
Example: User enters 8. My code takes the 8 and multiplies it by a number I set, in this case 6. I then need to take the product 48 and multiply it by another of my numbers, then take that product multiply it again, take that product and so on for several steps. I know I shouldn’t have entered userNum each time but I’m not sure what I’m supposed to put and I wanted to make sure the code at least partially functional. :P If it’s confusing, let me know and I’ll edit it.
int firstNum;
firstNum = 6;
int secondNum;
secondNum = 60;
Scanner userInputScanner = new Scanner(System.in);
System.out.println ("Hello, my name is Ronnie. What is your name?");
String userName = userInputScanner.nextLine();
System.out.println ("Hello, " + userName + ". How many steps do you take in a ten second interval?");
String userNumString = userInputScanner.nextLine();
int userNum = Integer.parseInt(userNumString);
System.out.println("If you take " + userNum + " steps in a 10 second interval, you could potentially achieve...");
System.out.println ("Number of steps per minute: " + (userNum * firstNum) +"");
System.out.println ("Number of steps per hour: " + (userNum * secondNum) +"");