Remember, easier things are at the bottom, look from bottom up to find the first thing you think you need to practice.
- Write a program that calculates the average, minimum, and maximum grades for a class of students.
Variations:
- Read in grades from the user until they enter a sentinel value (what's a good one?)
- Before you read in grades, ask the user how many students they have. In this case, use a validation loop to check that the grades entered are "legal" grades.
- Write a program using a loop to convert a String to all lowercase letters. Store the result in the original string.
- Write a program that reads in an input string and stores it backwards in another string. (e.g. "Test Input" becomes "tupnI tseT").
- Write a program that reads two integer numbers from the user and then prints out all the of the numbers from the first one to the seccond one, inclusive.Inclusive means including the numbers that the user entered.
Variations:
- Print out all the numbers from the last to the first (change of order of print.
- Make sure the code works if a larger number is typed in first.
- Test negative numbers.
- Change inclusive to exclusive (not including the numbers the user entered).
- Ask the user for a third value and only print out the numbers between the first 2 values that are a multiple of the third value.
- Write a program with a switch statement to read in a number from a user and print out "negative" if negative, "zero" if zero, "even" if positive and even, and "odd" if positive and odd.
Variations:
- Print out negative, zero or positive ADDITIONALLY print out even or odd for all values.
- Do these same programs using if statements
- Write a program with a switch statement that prints out the chapter names of our textbook, when the user enters the chapter number. (e.g. The user inputs 6, you output "Arrays".
Variations:
- Deliberately remove a switch statement to see what happens.
- Write a program that prints out "Cool" if the sentence entered by the user is of odd length (including
spaces and punctuation) and "Phat" if it is of even length.
Modify that program to only pritn out "Cool" or "Phat" in the case where the sentence ends with an
explanation point. In all other cases, output the first word of the sentence.
- Ask the user to enter an integer. If it is greater than 100 or less than 0, print out "That is not a valid grade".
Otherwise, printout the letter grade that that score is worth.