Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a C++ program to implement this task. (50 pts) Percentage marks attained by a student in three exams are to be entered into

1. Write a C++ program to implement this task. (50 pts) Percentage marks attained by a student in three exams are to be entered into a computer, using the keyboard. An indication of Pass or Fail is given out after the three marks are entered. The criteria for passing are as follows: A student passes if all three examinations are passed. Additionally a student may pass if only one subject is failed and the overall average is greater than or equal to 50. The pass mark for an individual subject is 40. Make use of a named constant for defining the pass mark of 40.

SAMPLE RUN 1 (user entered values are in blue) Enter the 3 marks, separated by a space: 75 85 90 You entered: Grade_1 = 75 Grade_2 = 85 Grade_3 = 90 Average Grade: 83.3333 You Passed :-)

SAMPLE RUN 2 (user entered values are in blue) Enter the 3 marks, separated by a space: 35 40 87 You entered: Grade_1 = 35 Grade_2 = 40 Grade_3 = 87 Average Grade: 54 You Passed :-)

SAMPLE RUN 3 (user entered values are in blue) Enter the 3 marks, separated by a space: 35 40 50 You entered: Grade_1 = 35 Grade_2 = 40 Grade_3 = 50 Average Grade: 41.6667 You Failed :-(

SAMPLE RUN 4 (user entered values are in blue) Enter the 3 marks, separated by a space: 35 38 39 You entered: Grade_1 = 35 Grade_2 = 38 Grade_3 = 39 Average Grade: 37.3333 You Failed :-(

2. You have to use a switch statement in this program. Write a C++ program which will compute the area of a square (area = side2) or a triangle (area = (base * height)/2) after prompting the user to type the first character of the figure name (t or s). If the user choses triangle, prompt them to enter the base and height and then compute and output the area of the triangle. If the user selects a square prompt them to enter the length of side of the square, and compute the area and out the area of the square. If the user enters a letter other than t or s, your program should print "Invalid entry" and end.

SAMPLE RUN 1 (user entered values are in blue) Enter t to compute area of triangle or s for square: a Invalid entry Done

SAMPLE RUN 2 (user entered values are in blue) Enter t to compute area of triangle or s for square: t You entered t for triangle Enter base: 4.5 Enter height: 6.5 Area of triangle of base 4.5 and height 6.5 is 14.625 Done

SAMPLE RUN 3 (user entered values are in blue) Enter t to compute area of triangle or s for square: s You entered s for square Enter length of side: 5.25 Area of sqaure of side length 5.25 is 27.5625 Done

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions