Write a complete program to output your first name on line 2. your last name on
ID: 3665338 • Letter: W
Question
Write a complete program to output your first name on line 2. your last name on line 4. and your birth state on line 7 using one cout. Add to your program to output your first name on line 9 using one cout. your last nameon line 11 using another cout, and then your birth state on line 14 using another cout. Part 2 20 Points Write a complete program to find the weighted average of 3 double numbers imputed by the user using your equation based on the last digit of your student ID and then output the average using a statement of your selection, where E = even = 0, 2, 4, 6, 8; O = odd = 1, 3, 5, 7, 9:Explanation / Answer
//PART-2.
/**C++ program that prompts user to enter
a, b and c and finds the last digit of the student
id and based on the last digit, the average
of three numbers.*/
#include<iostream>
using namespace std;
//SET student ID
#define STUDENT_ID 1234
int main()
{
//declare three variables
double a;
double b;
double c;
double average=0;
int lastDigit=STUDENT_ID%10;
//read a
cout<<"Enter a value : ";
cin>>a;
//read b
cout<<"Enter b value : ";
cin>>b;
//read c
cout<<"Enter c value : ";
cin>>c;
//Check if lastDigit is odd
if(lastDigit%2==1)
{
//find average
average=(18*a+12*b-6*c)/15.0;
}
else
{
//Check if lastDigit is odd
//find average
average=(12*a-3*b+15*c)/15.0;
}
cout<<" Student ID : "<<STUDENT_ID<<endl;
//print average
cout<<"Average :"<<average<<endl;
//pause the program output on console until user enters a key
system("pause");
return 0;
}
-------------------------------------------------------------------------------------------------------------------------------------------------
sAMPLE OUTPUT:
Enter a value : 5
Enter b value : 6
Enter c value : 8
Student ID : 1234
Average :10.8
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.