Download Intro - Solon City Schools

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
*Formatting: The output values in Programs 1 and 3 should
have commas and 4 digits to the right of the decimal.
Intro – If Practice Assignments (with printf) – Programs 1 to 6
No pseudocode necessary for this assignment (unless you are asking for help.)
Program 1* – lastname_ifFollowingDirections -- Write a program that does the following:
a. Prompt the user for an integer between 1 and 50 inclusive ( ‘inclusive’ means including
1 and 50).
b. If the user followed directions (and entered a value in the correct range), congratulate
them and attractively display the square root of the number that the user entered.
c. If the user did not follow directions, berate them (civilly).
Program 2 – lastname_ifDivisor – Write a program that does the following:
a. Prompt the user for a number and a divisor (both integers).
b. If the divisor does NOT evenly divide the number, tell the user that it is NOT an even
division.
c. If the divisor DOES evenly divide the number, tell the user two things: (1) that it IS an
even division and (2) what number divided by divisor equals.
FREE MONEY: Programs 3 and 4 must be if/else ladders. Be sure that they each have a
standalone else.
Program 3* – lastname_ifIsItBigger -- Write a program that does the following:
a. Ask the user for two ints, first and second.
b. Does one of three things:
i. If first > second, says “First is bigger” and attractively displays firstsecond
ii. If first < second, says “Second is bigger” and displays first X second
iii. If the two numbers are equal, says “Equal” and displays 2(first X second)
Program 4 – lastname_ifLetterGrade– Write a program that does the following:
a. Uses an if/else ladder
b. Asks the user to enter a number (an integer) that represents the user’s percent in class.
Precondition: The user will ONLY enter numbers from 0 to 100 inclusive.
c. Attractively displays the user’s letter grade, using Solon’s 10% range:
90 to 100 = A, 80 to 89 = B, 70 to 79 = C, etc.
FREE MONEY: Program 5 must be a nested if/else
Program 5 -- lastname_ifGuessANumber -- Write a program that uses a NESTED if/else to do the
following:
a.
b.
c.
d.
e.
D:\841014363.doc
05/14/17 2:03 AM
Stores a secret target integer between 1 and 20 (inclusive) in a constant variable
(without input from the user).
Asks the user to guess a number between 1 and 20.
Uses an if else structure to tell the user one of the following:
i. if the guess was correct.
ii. if the guess was incorrect. However, if the guess was incorrect, tell the user one of
the following:
1. Say the words “Incorrect, but a nice guess” if the guess was close – if it
was within 2 of the target number
2. Say the words “Incorrect, and a lousy guess” if the guess was not close –
it was not within 2 of the target number
You MUST use a NESTED IF ELSE to get full credit for this assignment. It is possible to
complete this assignment without nesting, but you should not.
The program must work for ANY secret target number. Your grader will change your
secret number to a different value before testing.
Program 6 -- lastname_ifNames
For this part of the assignment, you will use your notes regarding Strings and String equality entitled
String Variables and the .equals() method.
Write a program that uses a nested if/else or an if else ladder to determine if the user shares
any name or names with you. It should do the following:
1. Without any input from the user, it should store your first and last name in two separate String
variables.
2. It should then ask the user to enter his or her first and last name separately.
3. Based on the user’s entry, the program should then give the user one of four responses:
a.
b.
c.
d.
We
We
We
We
have the same first and last names.
have only the same first name.
have only the same last name.
do not have the same first or last name.
This should be an easy assignment. Be careful that you choose your if/else structure properly.
*Formatting: The output values in Program 1 and Program 3 should have commas and 4 digits to
the right of the decimal.
Also available:
BONUS Police Sketch Assignment (in Mr. McKeen’s OUT box and/or web page) – This is a fun,
creative, and relatively easy bonus.
D:\841014363.doc
05/14/17 2:03 AM