Question: C + + In this program, you will be reading a series of characters from input and measuring the value of the characters passed in
C
In this program, you will be reading a series of characters from input and measuring the value of the characters passed in
There will be a series of n lowercase characters provided via standard input. You will read these n characters and measure the value of each of these individual characters using the following key of values:
a b c x y z
Each of these characters will be on an individual line by themselves. The input will be terminated with the character on the final line of standard input.
You must keep track of the total value as you read each character. Your reading of the characters will be terminated in one of two ways. The first is that you will read all of the characters from input and output the final value of all of them collectively with a newline after this number. The second is that you will terminate early because the total goes over
If reading a character causes the value to go over you will print two lines of text to output. The first line will read Too Many and have a newline follow it The second line will be how many characters were read up to the point of going over the total of value of including the character which caused the overage. A newline will follow this.
An example of this would be reading in a series of the character z from input. You would read of this character before going over the value Once you read this th z and broke the threshold, you would print out:
Too Many
This task will require you using your knowledge of loops, conditions, and ASCII.
Submit your code in a file named progcpp to Gradescope.
Sample Test Cases
InputOutputa
a
a
a
f
d
r
k
e
i
t
h
x
y
z
a
b
c
x
y
z
Too Many
These three floating point numbers tell you:
The width of a rectangle, x
The length of a rectangle, y
The side length of a square, z
These values will be no larger than
You need to add error checking for these three values. Each of these values must be at least in size. Meaning if a size for any of these three variables is less than then you will exit immediately. If this case occurs, you will only print Invalid Side Values, followed by a newline, and immediately exit.
You will make two separate comparisons between the rectangle and the square:
Determine if the square fits inside of the rectangle
Determine which shape has a larger area
For determining if the square fits inside of the rectangle, you will need to see if the length of each of the squares sides is exclusively smaller than the length and width of the rectangle. In other words, are x and y larger than z If they are, then the square can fit inside the rectangle.
If the square fits inside of the rectangle, you will print Ja Ja and if it does not you will print Nein Nein. What you print here will have a newline follow it
For determining which shape has a larger area, you will need to calculate area of each of the shapes. The formula for generally calculating the area of a rectangle is length width which will be used here for both shapes. For the rectangle, you will multiply x y and for the square you will multiply z z
You will print the name of which shape has the larger surface area. If the rectangle is larger, you will print Rectangle. If the square is larger you will print Square. If they have the same surface area, print Equal. What is printed here will also have a new line follow it
Remember that your output must match exactly with the test cases, and you should compare what Gradescope expects with your output closely so you can see the differences between them. Capitalization, spacing, and newlines will impact correctness against a test case.
Submit your code in a file named progcpp to Gradescope.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
