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

Write a program that asks the user to enter an integer n then display the follow

ID: 3835140 • Letter: W

Question

Write a program that asks the user to enter an integer n then display the following menu: a. Display n^2.5. b. Display sin(n). c. Is n divisible by 10? If the user select a or b, the result should be displayed on the screen. "Yes" or "No" should be displayed when c selected, otherwise, prompt the user that the input is invalid. Write a program that reads six scores by asking the user to enter scores ranging between 0-100. Your program should find and print how many students passed (scores between 60 and 100 -inclusive). Make sure to validate restrict the user input to 0-100

Explanation / Answer

Ans 1: Codes have been perfectly checked in codeblocks.

#include<iostream>
#include<math.h>

using namespace std;
int main()
{
int num; //input for number
char chs; //chs is for choice
cout<<"Please enter a number: "; //taking input for a number
cin>>num;
cout<<"choose option: ";//displaying menu of choices
cout<<"a. Display num^2.5 ";
cout<<"b. Display sin of num. ";
cout<<"c. Is num divisible by 10? ";
cin>>chs; //inputting choice   
if(chs=='a') //performing operations according to the choice provided
{
cout<<pow(num,2.5);
}

else if(chs=='b')
{
cout<<sin(num);
}

else if(chs=='c')
{
if((num%10)==0) //checking whether the number is divisible by 10
cout<<"Yes";
else
cout<<"No";
}
else
cout<<"Invalid input!!";

return 0;
}

Ans 2:

#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
int score[6],cnt=0; //array of scores is declared and cnt to count passed students
cout<<"Enter scores for the six students in between 0-100. ";//taking input for scores
for(int i=0;i<6;i++)
{
cin>>score[i];
if((score[i]<0)||(score[i]>100)) //checking whether no. entered is not between 0-100
{
cout<<"error wrong input!!";
exit(0); //if "yes" then terminate the program
}
}

for(int j=0;j<6;j++)
{
if((score[j]>=60)&&(score[j]<=100)) // counting no. of students passed
{
cnt++;
}
}
cout<<"The number of students who have passed(60-100) is "<<cnt;
return 0;
}

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