math analysis b - 1.cdn.edl.io web viewgo to the fairfax website and download and ... have it...

1
AP Computer Science Name: Test 10/6/2014 Period: Go to the Fairfax website and download Magpie2real.java and MagpieRunner2real.java files. Save the files into your Activity2 folder. 1. Alter the code: Have it respond “Good for you.” when the statement contains the word “well” or “better”. For example, a possible statement and response would be: Statement: I did well on the test? Repsonse: Good for. Have it respond favorably when it sees the names of your food you like. For example, a possible statement and response would be: Statement: I ate pizza. Response: Yummy . Take a screen shot of your code. Run the program and take screen shots of the response after you type “How do you feel?” and “I watched ------movie”. 2. Have the code check that the statement has at least one character. You can do this by using the trim method to remove spaces from the beginning and end, and then checking the length of the trimmed string. If there are no characters, the response should tell the user to enter something. For example, a possible statement and response would be: Statement: Response: Say something, please. Hint: The code you use should include statement.trim().length() == 0 Run the program and input a blank space. Take a screen shot of the response. ****Email all screenshots to [email protected] Don’t forget to include your name!

Upload: truongquynh

Post on 05-Feb-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Math Analysis B - 1.cdn.edl.io  Web viewGo to the Fairfax website and download   and ... Have it respond “Good for you.” when the statement contains the word “well

AP Computer Science Name:Test 10/6/2014 Period:

Go to the Fairfax website and download Magpie2real.java and MagpieRunner2real.java files. Save the files into your Activity2 folder.

1. Alter the code: Have it respond “Good for you.” when the statement contains the word “well” or “better”. For example, a possible statement and response would be:

Statement: I did well on the test?Repsonse: Good for.

Have it respond favorably when it sees the names of your food you like. For example, a possible statement and response would be:

Statement: I ate pizza.Response: Yummy .

Take a screen shot of your code. Run the program and take screen shots of the response after you type “How do you feel?” and “I watched ------movie”.

2. Have the code check that the statement has at least one character. You can do this by using the trim method to remove spaces from the beginning and end, and then checking the length of the trimmed string. If there are no characters, the response should tell the user to entersomething. For example, a possible statement and response would be:Statement:

Response: Say something, please.

Hint: The code you use should include statement.trim().length() == 0

Run the program and input a blank space. Take a screen shot of the response.

****Email all screenshots to [email protected] Don’t forget to include your name!