Lab 5

  1. 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.
  2. 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
  3. 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".
  4. Example run of program:
    Enter a month: 7 31 days

  5. 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.
  6. Sample run of program:
    Enter a numeric score: 97 A
  7. 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."
  8. 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.
  9. 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".
  10. Sample run of program:
    Enter two numbers: 45 55 true

    Sample run of program:
    Enter two numbers: 102 -3 false