CS160 Lab 3 solution

$29.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (5 votes)

Objective:
Work with basic input commands.
Work with decision making commands.
Assignment
Part 1
Each input should generate a line of output for each of the specified tests. Do each test
independent of the other tests.
a) Ask for a year. State whether or not the year is with the range of 2000 to 2029 inclusive.
b) Ask for the number of credits a student has passed. State whether the student is a
freshman (0-23), sophomore (24-59), junior (60-89), or senior (90 or greater).
c) Ask for a grade point average. Using labels from some table I found, state whether the
student’s gpa is “Excellent” (= 4.0), “Very good” (>= 3.75), “Good” (>= 3.2), “Above
average” (>= 2.8), “Average” (>= 2.5), “Satisfactory” (>= 2.0), or “Poor” (< 2.0). d) Using the inputs from the previous two questions, state whether the student is eligible for graduation. For this question, to be able to graduate the student needs a gpa >= 2.5 and
have passed 120 credits. Do not ask for additional inputs in this question.
Each of the points listed above should generate its own output statement. All but d) will require
its own input statement.
An example of running the program might be as follows. The following IS NOT output from
running the program, so there may be typos.
Please enter a year: 1995
That year is not in the range of 2000 to 2029.
Enter number of credits passed: 63
You are a junior
Enter your gpa: 3.24
You gpa is Good
S
You are not eligible to graduate
Running it again might look like:
Please enter a year: 2021
That year is in the range of 2000 to 2029.
Enter number of credits passed: 127
You are a senior
Enter your gpa: 2.5
You gpa is Average
You are eligible to graduate
Part 2
Create a program that asks the user for an x and y value. Ask for the values one at a time.
Then, using the standard notation for identifying a point (x and y inside parenthesis, separated
by a comma), repeat the location and the Cartesian coordinate quadrant in which the x,y
position is located. You can assume that neither x or y will be 0. Use the image below for
quadrant information.
Example:
Please enter a value for x: 42
Please enter a value for y: 3
(42, 3) is in quadrant I.
(running the program again)
Please enter a value for x: -4
Please enter a value for y: 17
(-4, 17) is in quadrant II.
Part 3
In this order, ask for a number (float), a math operator (string), and another number (float). Then
perform the requested mathematical operation. The only valid operations are “+”, “-“, “*”, and
“/”. This program will not address integer division or the modulus operator.
• If the operator is not valid, state that the operator is invalid and do nothing else in the
program.
• When performing division, do not allow a division by zero error. If the denominator is zero,
state that you cannot perform the requested action. Remember 0 is a valid value for
addition, subtract, multiplication or as the numerator when performing division.
• No other error checking is required. You can assume all values enter for numbers will be
valid numbers.
Example:
Enter the first number: 40
Enter the operation: +
Enter the second number: 20
The result is: 60
(running the program again)
Enter the first number: 10
Enter the operation: %
Enter the second number: 2
Invalid operator