Concept explainers
Each of the following
A)
cout << "Enter your 3 test scores and I will ";
<< "average them:";
int scorel, score2, score3,
cin >> scorel >> score2 >> score3;
double average = (scorel + score2 + score3) / 3.0;
if (average = 100);
perfectScore = true; // Set the flag variable
cout << "Your average is " << average << endl;
bool perfectScore;
if (perfectScore);
cout << "Congratulations!\n";
cout << "That's a perfect score.\n";
cout << "You deserve a pat on the back!\n";
B)
double num1, num2, quotient;
cout << "Enter a number: ";
cin >> num1;
cout << "Enter another number: ";
cin >> num2;
if (num2 == 0)
cout << "Division by zero is not possible.\ n";
cout << "Please run the program again";
cout << "and enter a number besides zero.\n";
else
quotient = num1 / num2;
cout << "The quotient of " << num1 <<
cout << " divided by " << num2 << " is ";
cout << quotient << endl;
C)
int testScore;
cout << "Enter your test score and I will tell you\n";
cout << "the letter grade you earned: ";
cin >> testScore;
if (testScore < 60)
cout << "Your grade is F. \n";
else if (testScore < 70)
cout << "Your grade is D. \ n";
else if (testScore < 80)
cout << "Your grade is C. \ n";
else if (testScore < 90)
cout << "Your grade is 8. \ n";
else
cout << "That is not a valid score.\n";
else if (testScore <= 100)
cout << "Your grade is A. \n";
D)
double testScore;
cout << "Enter your test score and I will tell you\n";
cout << "the letter grade you earned: ";
cin >> testScore;
switch (testScore)
{ case (testScore < 60. 0):
cout << "Your grade is F.\n";
case (testScore < 70.0):
cout << "Your grade is D.\n";
case (testScore < 80.0) :
cout << "Your grade is C.\n";
case (testScore < 90.0):
cout << "Your grade is B.\n";
case (testScore <= 100.0):
cout << "Your grade is A.\n";
default: cout << "That score isn't valid\n"; }
}
Trending nowThis is a popular solution!
Chapter 4 Solutions
Starting Out with C++: Early Objects (9th Edition)
Additional Engineering Textbook Solutions
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Degarmo's Materials And Processes In Manufacturing
Java: An Introduction to Problem Solving and Programming (8th Edition)
Mechanics of Materials (10th Edition)
- Please help me to code this Python It is High/Low Card Game The pyex is example of outputarrow_forwardprogram itarrow_forwardText-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. Modify the application below (week3.py) so that the selection variable is sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. You will need to add an if statement in the choice() function to make the correct selection.arrow_forward
- Background: Game Rules The rules to the (dice) game of Pig: You will need 2 dice. To Play: a. The players each take turns rolling two die. b. A player scores the sum of the two dice thrown (unless the roll contains a 1): If a single number 1 is thrown on either die, the score for that whole turn is lost (referred to as “Pigged Out”). A 1 on both dice is scored as 25. c. During a single turn, a player may roll the dice as many times as they desire. The score for a single turn is the sum of the individual scores for each dice roll. d. The first player to reach the goal score wins unless a player scores higher subsequently in the same round. Therefore, everyone in the game must have the same number of turns. Execution and User Input This program is quite interactive with the user(s) and will take in the following information; please review the sample input / output sessions for details; we describe them again here emphasizing input. The program will prompt for the number of…arrow_forwardR studio : profit margin for each month - equals to profit a after tax divided by revenue profit.margin <- round(profit_after_tax/revenue, 2)*100 profit.margin Result: 12 18 -30 -22 -5 63 50 28 23 -11 4 53 How to change the results based on the note: All results need to be presented as vectors. Results for dollar values need to be calculated with $0.01 precision, but need to be presented in Units of $1,000 (i.e. 1k) with no decimal points. Results for the profit margin ratio need to be presented in units of % with no decimal points. Note: You colleague has warned you that it is okay for tax for any given month to be negative (in accounting terms, negative tax translates into a deferred tax asset).arrow_forwardscore = 0rating = int(input("Enter star rating: "))shares = int(input("Enter number of shares: "))if rating == 1 or 2: if shares < 1000: score = rating*shares*2 print("The score is : ", score) if shares >= 1000: score = rating*shares print("The score is : ", score)if rating == 3 or 4: if shares < 2500: score = rating*shares*3 print("The score is : ", score) if shares >= 2500: score = rating*shares print("The score is : ", score)if rating == 5: if shares < 5000: score = rating*shares*4 print("The score is : ", score) if shares >= 5000: score = rating*shares print("The score is : ", score) This is what I have so far. When I do 3 stars 1000 shares it says: The score is : 3000The score is : 9000 idk why it does the 3000 one These are the tests it has to pass 1) Test: 1 Star, 450 Shares 2) Test: 2 Stars, 1500 Shares 3) Test: 3 Stars, 1000 Shares 4) Test: 4 Stars, 3500…arrow_forward
- JAVA:arrow_forward* Question Completion Status: A Moving to another question will save this response. Question 9 Given the function F(X,Y,Z) =XZ + Z(X'+ XY), the equivalent, most simplified Boolean representation for F is O a. Z+XYZ O b.XZ O c. Z O d.Z+YZ A Moving to another question will save this response. مشمس 36°Carrow_forwarduse visual basic Depreciation to a Salvage Value of 0 . For tax purposes an item may be depreciated over a period of several years, n . With the straight-line method of depreciation , each year the item dpreciates by 1/nth of it original value. with the double-declining-balance method of depreciation, each year the item depreciate by 2/nths of its value at the beginning of that year.(In the final year it is depreciated by its value at the beginning of the year. ) Write a program that performs the following tasks:(a) Request a description of the item, the year of purchase, the cost of the item, the number of years to be depreciated (estimated life), and the method of depreciation. The method of depreciation should be chosen by clicking on one of two buttons.(b) Display a year- by-year description of the depreciation. See Fig. 6.15 .arrow_forward
- The value of x at the end.int x = 1;x = x + 1;x++;arrow_forward16 Type the correct answer in the box. Use numerals instead of words. If necessary, use / for the fraction bar. var num2 = 32; var num1 = 12; var rem=num2 % num1; while(rem> 0) { num2 = num1; num1 = rem; rem =num2 9% num1; document.write(num1): The output of the document.write statement at the end of this block is Reset Next m. All rights reserved. 5896arrow_forward1: You are given a list of students’ names and their test scores. Design algorithm that does thefollowing:a. Calculate the average test scores.b. Determines and prints the names of all the students whose test scores are below theaverage test score.c. Determines the highest test score.d. Prints the names of all the students whose test scores are the Same as the highest testscore.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage