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
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)
- Coin Toss Write a function named coinToss that simulates the tossing of a coin. When you call the function, it should generate a random number in the range of 1 through 2. If the random number is 1, the function should display "heads". If the random number is 2, the function should display "tails". Demonstrate the function in a program that sks the user how many times the coin should be tossed and the coin then simulates the tossing of the coin that number of times.arrow_forwardComplete the following Codearrow_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
- be recor #include #include minutes #include limit on int func(int, int, int, int); main(){ srand(time(NULL)); int a, b, c, fNum; printf("Choose three different numbers between 0-39:"); scanf ("%d%d%d", &a, &b, &c); fNum = func (a, b, c, 25); printf("\nThe result: %d", fNum); } int func (int ul, int u2, int u3, int iter){ srand (time (NULL)); int n1=0, i=0, count=0; for (;iarrow_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_forwardTranscribed Image Text Write a program that asks for the principal, the annual interest rate, and the number of times the interest is compounded. It should display a report similar to the following: Interest Rate: 4.25% Times Compounded: 12 Principal: $ 1000.00 Interest: 43.33 Final balance: $ 1043.33arrow_forwardPython elif ifarrow_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_forwardStatic Variable: a variable whose lifetime is the lifetime of the program (static int x;) Dynamic Variable: It is a pointer to a variable (int *x;) Is this comparison true?arrow_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_forwardCould you write function comments for def quadratic(a,b,c,x) And def print_quad(a,b,c,x) Please follow the comment rule.arrow_forward5- int fun() int a, b, c, result; cout>a>>b>>c; cout<<"The result is "; reutrn result; } The error is Your answerarrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage