- Write a program that prompts the user for three numbers, and stores those three numbers in variables. Compare the three numbers using if statements and and print "increasing" if they are in increasing order, "decreasing" if they are in decreasing order, and "neither" otherwise. Here increasing means strictly increasing, with each value larger than its predecessor.
Sample run of program:
Enter three numbers: 11 21 22
Increasing
Sample run of program:
Enter three numbers: 11 17 17
Neither
Sample run of program:
Enter three numbers: 11 7 2
Decreasing
- Write a program that asks the user to enter a month (1 for January, 2 for February, and so on) and then prints the number of days in the month. For February, print "28 or 29 days".
Example run of program:
Enter a month: 7
31 days
- Write a program that asks the user to enter a numeric score. The program will print the letter grade that corresponds to the score entered by the user.
- Above 80: A
- 60 to 80: B
- 50 to 59: C
- 45 to 49: D
- Below 44: F
Sample run of program:
Enter a numeric score: 97
A
- Write a program that asks the user to enter three angle values in degrees. The program will check whether a triangle can be formed by the given values for the three angles. If a triangle can be formed, check whether the triangle is an equilateral triangle or a right triangle. If the triangle is not equilateral or right, print "The triangle is neither equilateral nor right."
- Angles are entered in degrees.
- If the sum of all three angles is 180, then a triangle can be formed.
- An equilateral triangle has three 60 degree angles.
- A right triangle has one 90 degree angle.
Sample run of program:
Enter an angle in degrees: 45
Enter an angle in degrees: 45
Enter an angle in degrees: 90
A triangle can be formed from these angles.
The triangle is a right triangle.
Example run of program:
Enter an angle in degrees: 50
Enter an angle in degrees: 70
Enter an angle in degrees: 60
A triangle can be formed from these angles.
The triangle is neither equilateral nor right.
Example run of program:
Enter an angle in degrees: 10
Enter an angle in degrees: 20
Enter an angle in degrees: 30
A triangle cannot be formed from these angles.
- Write a program that prompts the user for two numbers. If the sum of the numbers is greater than 100, print "true", otherwise print "false".
Sample run of program:
Enter two numbers: 45 55
true
Sample run of program:
Enter two numbers: 102 -3
false