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

2 (A). What header files must be included in the following program? int main() {

ID: 3934603 • Letter: 2

Question

2 (A). What header files must be included in the following program?

int main()

{

double amount = 89.7;
cout << fixed << showpoint << setprecision(1);

cout << setw(8) << amount << endl;
return 0;

}

(B). Trace the following programs and tell what each will display. (Some require a calculator.)

a) (Assume the user enters 38711. Use a calculator.)

#include

using namespace std;

int main() {

double salary, monthly;
cout << "What is your annual salary? ";
cin >> salary;
monthly = static_cast(salary) / 12;
cout << "Your monthly wages are " << monthly << endl;

return 0;

}

(b)

#include
using namespace std;
#define WHO “Columbus”

#define DID "sailed"

#define WHAT "the ocean blue."

int main() {

const int WHEN = 1492;

cout<<"In"<

<

return 0;

}

(c)(Assume the user enters George Washington.)

#include
#include

#include

using namespace std;

int main()
{

string userInput;

cout << "What is your name? ";
cin >> userInput;
cout << "Hello " << userInput << endl;

return 0;

}

(d)(Assume the user enters George Washington.)

#include
#include

#include

using namespace std;

int main()
{

string userInput;

cout << "What is your name? “;

getline(cin, userInput);
cout << "Hello " << userInput << endl;

return 0;

}

(C). The following program has some errors. Locate as many as you can.

#include <iostream>

using namespace std;

int main()
{

int number1, number2;
double quotient;
cout << "Enter two numbers and I will divide ";

cout << "the first by the second for you. ";
cin >> number1, number2;
quotient = double<static_cast>(number1)/number2;

cout << quotient

}

Explanation / Answer

A-

#include<iostram.h>- for cin and cout

this header file should be used

B(a) - The output will Be

Output- Your monthly waages are 3225.916667

B(c)- Hello Jeorge Washington

C- correct code is :

#include <iostream.h>

using namespace std;

int main()
{

int number1, number2;
double quotient;
cout << "Enter two numbers and I will divide ";

cout << "the first by the second for you. ";
cin >> number1;

cin>>number2 ;
quotient = static_cast<double>(number1)/number2;

cout << quotient

}

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