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
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting out with Visual C# (4th Edition)
Starting Out with Java: Early Objects (6th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Java How To Program (Early Objects)
- #include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_forward#include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_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_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_forwardThe 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_forward5- int fun() int a, b, c, result; cout>a>>b>>c; cout<<"The result is "; reutrn result; } The error is Your answerarrow_forwardPlease Don't Get Answers From Chegg!! Thank You!arrow_forwardThe following function has errors. Locate as many errors as you can. void getValue(int value&) { cout << "Enter a value: "; cin >> value&;}arrow_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