Question
This problem is considered from C++, I need to know the steps using the step-by-step function for me to fully understand on how to solve this tough problem.

Question 30 10 pts (SHORT ANSWER) Write three separate if blocks to check the following THREE conditions (number your answers
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Three separate if blocks for three conditions are-

1)The variables test score is of integer type because it is a number variable.

Condition given is that if  variable test score value lies outside the range of 0 and 100 then print message INVALID OUTSIDE RANGE 0-100

1st IF block statement

int testscore;

If((testscore<0) ||(testscore>100))

{  

Cout<<"INVALID: OUTSIDE RANGE 0-100";

}

Explanation of first if block

Here if condition is used that if test score is less than 0 (testscore < 0) or if test score is greater than 100 (testscore>100) and both the condition is joined by Or ( || ) symbol as OR specifies that either of two cases is true then whole if statement will evaluates to true and will print the message that number will be outside the range 0-100.

2) 2 nd IF block statement

int bonuspoints ;

If((bonuspoints>=1) &&( bonuspoints<=10))

{

Cout<<"VALID: INSIDE RANGE 1-10";

}

Explanation of 2 nd if block statement

Here if condition is used to check that if bonus points is greater than equal to 1 (bonuspoint>=1) and if bonus points is less than equal to 10 (bonuspoint<=10) as these two conditions is joined by AND operator && which specifies that both condition need to be true for making bonus points inside the range of 1 -10. if both conditions are true then only if statement will evaluate to true and print the messages "VALID:INSIDE RANGE 1-10"

3) 3 rd If block statement

Char lettergrade;

If((lettergrade=="A")|| (lettergrade=='a'))

{

Cout<<"CONGRATULATION ! YOU MADE AN A GRADE";

}

Explanation of 3 rd block if statement

Here lettergrade is a variable of type character here the if condition check for two cases if the letter grade is equal to 'A' or if letter grade equal to 'a' then print congratulations you made an A grade here both the conditions are joined by OR operators || which means that either of two conditions is true either grade is 'a' or 'A' then whole if condition become true and prints Congratulations you have made an A grade .

The copy code is as given below where three if block codes are combined ---

The code for the following program which contains three if block is---

#include <iostream>

int main() {
int test_score;
std::cout<<"Enter test score";
std::cin>>test_score;
if((test_score<0)||(test_score>100))
{
std::cout << "Invalid:outside range \n";
}
int bonus_points;
std::cout<<"Enter bonus_points";
std::cin>>bonus_points;
if((bonus_points>=1)&&(bonus_points<=10))
{
std::cout << "valid:inside range 1-10 \n";
}
char lettergrade;
std::cout<<"enter grade";
std::cin>>lettergrade;
if((lettergrade=='a')|| (lettergrade=='A'))
{
std::cout <<"CONGRATULATIONS YOU HAVE MADE AN A GRADE";
}
}

"Please refer to the screenshot of code to understand the indentation of the code "

Screenshot of code

1 } main.cpp E D saved Files #include <iostream> 2 3 - int main() { 4 int test_score; 5 std::cout<<Enter test score; 6 std:

Screen shot of outputs

clang++-7 -pthread -std=c++17 -o main & main.cpp ; ./main Enter test score -1 Invalid:outside range Enter bonus_points 5 valihttps://PeruHollowInternalcommand.five-nine.repl.ru o > clang++-7 -pthread -std=c++17 -o main main.cpp /main Enter test score

1 } main.cpp E D saved Files #include <iostream> 2 3 - int main() { 4 int test_score; 5 std::cout<<"Enter test score"; 6 std::cin>>test_score; 7 if((test_score<0)||(test_score >100)) 8 { 9 std::cout << "Invalid: outside range \n"; 10 11 int bonus_points; 12 std::cout<<"Enter bonus_points"; 13 std::cin>>bonus_points; 14 if((bonus_points>=1)&& (bonus_points<=10)) 15 - 16 std::cout << "valid:inside range 1-10 \n"; 17 18 char lettergrade; 19 std::cout<<"enter grade"; 20 std::cin>lettergrade; 21 if((lettergrade=='a')|| (lettergrade=='A')) 22 23 std::cout <<"CONGRATULATIONS YOU HAVE MADE AN A GRADE", 24 25 { } { } } Code Console Commands

clang++-7 -pthread -std=c++17 -o main & main.cpp ; ./main Enter test score -1 Invalid:outside range Enter bonus_points 5 valid:inside range 1-10 enter grade A CONGRATULATIONS YOU HAVE MADE AN A GRAD E:

https://PeruHollowInternalcommand.five-nine.repl.ru o > clang++-7 -pthread -std=c++17 -o main main.cpp /main Enter test score 105 Invalid:outside range Enter bonus_points 10 valid:inside range 1-10 enter grade a CONGRATULATIONS YOU HAVE MADE AN A GRAD

We were unable to transcribe this image

We were unable to transcribe this image

https://PeruHollowInternalcommand.five-nine.repl.ru o > clang++-7 -pthread -std=c++17 -o main main.cpp /main Enter test score 105 Invalid:outside range Enter bonus_points 10 valid:inside range 1-10 enter grade a CONGRATULATIONS YOU HAVE MADE AN A GRAD

We were unable to transcribe this image

clang++-7 -pthread -std=c++17 -o main & main.cpp ; ./main Enter test score -1 Invalid:outside range Enter bonus_points 5 valid:inside range 1-10 enter grade A CONGRATULATIONS YOU HAVE MADE AN A GRAD E:

https://PeruHollowInternalcommand.five-nine.repl.ru o > clang++-7 -pthread -std=c++17 -o main main.cpp /main Enter test score 105 Invalid:outside range Enter bonus_points 10 valid:inside range 1-10 enter grade a CONGRATULATIONS YOU HAVE MADE AN A GRAD

Add a comment
Know the answer?
Add Answer to:
This problem is considered from C++, I need to know the steps using the step-by-step function...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is used as C++ How do I even figure this out at all? Please help...

    This is used as C++ How do I even figure this out at all? Please help me solve this tough question Question 30 10 pts (SHORT ANSWER) Write three separate if blocks to check the following THREE conditions (number your answers): 1. If the number variable testScore is outside the range of 0 through 100 (excluding both those scores), print the message: "INVALID: OUTSIDE RANGE 0-100" 2. If the number variable bonusPoints is inside the range 1 through 10 (including...

  • This is a C++ statement, how do I solve this problem using the void function? Question...

    This is a C++ statement, how do I solve this problem using the void function? Question 29 10 pts (SHORT ANSWER) Define a void function named swap2 Nums that accepts 2 integer reference parameters: num1 and num2. The function should then swap the two numbers. Use additional variable(s) as necessary. BIVA-AIK EE311xx, V TT 12pt Paragraph O words

  • This exercise is also from C++ How do I even figure this out? please help me...

    This exercise is also from C++ How do I even figure this out? please help me solve so I can get the answer correctly! Question 28 10 pts (SHORT ANSWER) Define a function named findEvenOrOdd that has 1 int parameter: num. When the function is called, it should use an if/else statement -OR- conditional expression to determine whether the variable num is an even or odd number and display appropriate message as follows: • If the value in num is...

  • please help ASAP need to complete soon needs to be done in C programing void countDays...

    please help ASAP need to complete soon needs to be done in C programing void countDays (unsigned month, unsigned day): Given a month and day, print a message based on the following conditions (which we would suggest testing in order). Don't get overwhelmed by the number of conditions--the function gets a bit long, but the function body shouldn't be that complex: • If the month is invalid, print Invalid month: followed by the month argument (for example, Invalid month 13)...

  • I need help in Python. This is a two step problem So I have the code...

    I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...

  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

  • I need a simple program in C language that calculates the values of Sine, Cosine, and...

    I need a simple program in C language that calculates the values of Sine, Cosine, and Tangent of values given in degrees. It has to be a range of values between 0 and 360(integer values). The output should be a table of values showing Sin, Cos and Tan values. The complete computation and printing of the table must be done inside a function. The function also returns to the main program with 3 output arguments: It also needs to show...

  • Need some help I am not understanding this programming class at all. We are using Microsoft...

    Need some help I am not understanding this programming class at all. We are using Microsoft visual studio with python in console mode to complete these labs. Double-click to hide white space CIS115 Week 4 Lab Overview Title of Lab: Multiplication Table in Python Summary This week's lab is to create a simple multiplication table using nested loops and if statements. Prompt the user for the size of the multiplication table (from 2x2 to 10x10). Use a validation loop to...

  • I want to this question solution by programming c code. I need this solution as soon...

    I want to this question solution by programming c code. I need this solution as soon as possible i have to submit this code after 24 hours. please someone help this question thanks :D Programming Question: (15pts) Assume a finite number of resources of a single resource type must be managed. Processes may ask for a number of these resources and will return them once finished. If all resources are in use the request is denied and the process terminates....

  • C++ Hey, I really need help with this lab. I don't understand the function part at...

    C++ Hey, I really need help with this lab. I don't understand the function part at all. It'll be great way for me to understand. Than you Functions and loops: Write a program that will ask the user which type of triangle they would like to draw on the characters. The choices are screen with left-top-big left-bottom-big right-top-big right-bottom-big Get the user's choice, ask how big it should be, and then draw the shape. After each successful drawing, ask the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT