I'm new to programming. I have code for my Finch robot that simply loops a zigzag section after the user inputs how many times it should loop for, but how do I input another question that asks how long each zigzag section should be?
For example, the first question I ask is how many zigzag sections the user wants to loop for, but I also want to ask how long each zigzag segment should be (how long each line should be before it turns the other way).
Code:
Finch myFinch = new Finch();
Scanner sc = new Scanner(System. in );
System.out.println("Welcome! Complete the following entries");
System.out.println("Number of zigzag sections: ");
int noOfTimes = sc.nextInt();
do {
myFinch.setLED(Color.green);
myFinch.buzz(600, 2250);
myFinch.setWheelVelocities(180, 0, 750);
myFinch.setWheelVelocities(100, 100, 1500);
myFinch.setLED(Color.red);
myFinch.buzz(600, 2350);
myFinch.setWheelVelocities(0, 180, 850);
myFinch.setWheelVelocities(180, 180, 1500);
noOfTimes--;
} while ( noOfTimes > 0 );
myFinch.quit();
System.exit(0);
Check java
Scannerdoccumentation hereCode sample to accept multiple inputs