Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Compare the following two segments of c++ code. Predict what will be the output

ID: 3537944 • Letter: C

Question

Compare the following two segments of c++ code. Predict what will be the output of each segment for various grade values. Then, use a small test program to confirm or correct your answer. Describe whether you were correct or not. If you were not correct, describe what you learned from this comparison.

if (grade >= 65)                                                         if (grade >= 65)

   cout << %u201CYou Pass!%u201D << endl;                                 cout << %u201CYou Pass!%u201D << endl;

else                                                                                 cout << %u201CGreat Work!%u201D << endl;

   cout <<%u201DSorry, you failed%u201D << endl;                  else

                                                                                        cout << %u201CSorry, you failed%u201D << endl;

Make sure you include your predictions, the values you tested, and the results of your tests in your response to this question.



Compare the following two segments of c++ code. Predict what will be the result of each segment for various grade values. Then, use a small test program to confirm or correct your answer (you can add another segment of code to your existing test program - just comment out the code you used for the 1st question). Describe whether you were correct or not. If you were not correct, describe what you learned from this comparison.

if (grade = 100)                                                         if (grade == 100)

   cout << %u201CCongratulations!%u201D << endl;                    cout << %u201CCongratulations!%u201D << endl;

Make sure you include your predictions, the values you tested, and the results of your tests in your response to this question.



Compare the following two segments of c++ code. Predict what will be the result of each segment for various test values of x. Add another section of code to your test program to confirm or correct your answer. Describe whether you were correct or not. If you were not correct, describe what you learned from this comparison

if (x > 0 && x < 10)                                                   if (x > 0 || x < 10)

   cout << %u201CItem is range 1 to 9%u201D << endl;                 cout << %u201CItem is range 1 to 9%u201D << endl;

Make sure you include your predictions, your test values, and the results of your tests in your response to this question.



In your C++ test program, add another segment of code that will help you decipher the day of the week codes used in the college schedule.   Your program should ask the user to enter a single character representing the day of the week, either M, T, W, R, or F. Your program should accept the single character, and display the full day name as output. Accept both upper and lower case letters. Display an error if a character other than MTWRF is entered. You must use an if/else structure in your program.

When this code works, use this question response to identify any difficulties or errors you made when writing this code segment. How did you correct these errors?



Once your code for question #4 works, add another segment of code to it that will print the day of the week again, this time using a switch structure. Your program should work as it did before, except that you%u2019ll see the results twice. Again, once you've gotten this code to work, use this question to identify any errors you had when adding this section of code, and explain how you correctted them.



Write an algorithm that will find the largest of 3 numbers entered by the user. Remember, this is an algorithm, not a c++ program.

Explanation / Answer

Compare the following two segments of c++ code. Predict what will be the output of each segment for various grade values.
Then, use a small test program to confirm or correct your answer. Describe whether you were correct or not.
If you were not correct, describe what you learned from this comparison.

if (grade >= 65)
cout << "You Pass!" << endl;                                 
else                                                         
cout <<"Sorry, you failed" << endl;                 

IN ABOVE CASE.
when grade is >= 65 then only "you pass!" message will be printed.
otherwise "Sorry, you failed message will be printed"

if (grade >= 65)
cout << "You Pass!" << endl;
cout << "Great Work!" << endl;
else cout << "Sorry, you failed" << endl;

IN ABOVE CASE.
we get compilation ERROR.
error: 'else' without a previous 'if'

we have to use braces for correct syntax.

if (grade >= 65)
{
cout << "You Pass!" << endl;
cout << "Great Work!" << endl;
}
else { cout << "Sorry, you failed" << endl; }



if (grade = 100)                                                      
cout << "Congratulations!" << endl;                   

ABOVE CASE WILL BE EXECUTED ALL THE TIMES BECUASE grade will be assigned with 100
and every non -negative numbers C++ language treats as true.
thus "Congratulations!" will be printed all the time.


if (grade == 100)
cout << "Congratulations!" << endl;                   

IN ABOVE CASE , "Congratulations!" message will be printed only when grade is equal to 100.


if (x > 0 && x < 10)
cout << "Item is range 1 to 9" << endl;

IN ABOVE CASE, if x > 0 and x < 10 then "Item is range 1 to 9" message will be printed which is correct.

if (x > 0 || x < 10)
cout << "Item is range 1 to 9" << endl;

in above case atleast one needs to be true thus
if x>0 always "Item is range 1 to 9" message will be printed. so it wont check for second condition.

In your C++ test program, add another segment of code that will help you decipher the day of the week codes used in the college schedule.
Your program should ask the user to enter a single character representing the day of the week, either M, T, W, R, or F.
Your program should accept the single character, and display the full day name as output.
Accept both upper and lower case letters. Display an error if a character other than MTWRF is entered.
You must use an if/else structure in your program.

#include<iostream>
using namespace std;
int main()
{
char K;
cout << "enter a single character representing the day of the week, either M, T, W, R, or F.";
cin >>K;
cout << endl;
if(K!='M' && K!='T' && K!='W' && K!='R' && K!='F')
{
cout <<" IN VALID CHARACTER ENTERED" << endl;
}
else
{
if(K=='M') cout << " Monday " <<endl;
else if(K=='T') cout << " Tuesday " <<endl;
else if(K=='W') cout << " Wednesday " <<endl;
else if(K=='R') cout << " Thursday " <<endl;
else if(K=='F') cout << " Friday " <<endl;
}
return 0;
}


When this code works, use this question response to identify any difficulties or errors you made when writing this code segment
. How did you correct these errors?



Once your code for question #4 works, add another segment of code to it that will print the day of the week again,
this time using a switch structure. Your program should work as it did before, except that you'll see the results twice.
Again, once you've gotten this code to work, use this question to identify any errors you had when adding this section of code,
and explain how you correctted them.

#include<iostream>
using namespace std;
int main()
{
char K;
cout << "enter a single character representing the day of the week, either M, T, W, R, or F.";
cin >>K;
cout << endl;
if(K!='M' && K!='T' && K!='W' && K!='R' && K!='F')
{
cout <<" IN VALID CHARACTER ENTERED" << endl;
}
else
{
if(K=='M') cout << " Monday " <<endl;
else if(K=='T') cout << " Tuesday " <<endl;
else if(K=='W') cout << " Wednesday " <<endl;
else if(K=='R') cout << " Thursday " <<endl;
else if(K=='F') cout << " Friday " <<endl;
switch(K)
{
case 'M': cout << " Monday " <<endl; break;
case 'T': cout << " Tuesday " <<endl; break;
case 'W': cout << " Wednesday " <<endl; break;
case 'R': cout << " Thursday " <<endl; break;
case 'F': cout << " Friday " <<endl; break;
}
}
return 0;
}


Write an algorithm that will find the largest of 3 numbers entered by the user. Remember, this is an algorithm, not a c++ program.

let maximum = first number;
if second number > maximum
maximum = second number
if third number > maximum
maximum = third number
print maximum

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote