Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Java user input?

$
0
0
Hey guys, this is a homework question :P/>/>/>/>/>

final private static int testtime = 5000;

//Move the left wheel forward and backward
private static void RunLeftWheelTest(String s)
         {
	     System.out.println("\n"+"Running: "+s+"\n");
	     myf.setWheelVelocities(255,0,testtime/2);
	     myf.setWheelVelocities(-255,0,testtime/2);
         }
                                        
//Move the right wheel forward and backwards
private static void RunRightWheelTest(String s)
         {
             System.out.println("\n"+"Running: "+s+"\n");
	     myf.setWheelVelocities(0,255,testtime/2);
	     myf.setWheelVelocities(0,-255,testtime/2);
         }



The homework specifies that the time interval in which the robot moves backwards and forwards is user specified. Say for instance the user specifies 10 seconds, I'm assuming the robot would move forwards 5 seconds and backwards 5 seconds.

import java.util.Scanner;

Scanner option1 = new Scanner( System.in );
		
int backForwardTime;
		
backForwardTime = user_input.next();
		
System.out.print("Please specify your time interval for the Finch to travel backwards and forwards: ");
		
backForwardTime = user_input.next();



I attempted with the code^ but failed miserably. I tried to implement this http://www.homeandlearn.co.uk/java/user_input.html, and it's my first time attempting user input in Java and it's just not working.

Can you give me any tips/help please?

Thank you.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>