Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can some one help me with this code. To give a run down I am trying to use the robot class to type a city

Can some one help me with this code. To give a run down I am trying to use the robot class to type a city name, so I have a scanner input to recieve the city name and then convert the string into a char array and then in the Keypress robot object I have a loop that types each chacter until down. the problem is I dont know how to represent the char values when invoking the key press method. here is the code bit Im talking about

image text in transcribed

I tryed putting a1 or i in the parenthesis of the method neither seems to work. Help would be much appreciated

Scanner sc = new Scanner(System.in); System.out.print("Enter City"); string city = sc.next(); char [] a1 city.toCharArray(); for(int 1-0 ; 1 al.length; i++) { System.out.print(i); Keypress (a1); try robot = new Robot(); catch (ANTException e) e.printStackTrace); public static void Keypress (char i) f for( 1-0; i 20 ; i++) { robot.keyPress (KeyEvent.VK_SHIFT); robot.keyPress (i); robot.keyRelease(i); robot.keyRelease (KeyEvent.VK_SHIFT)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions