Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ if I choose gradYear = 2019 and currentYear = 2015, the below program doesnt work out well; it works fine for other conditions... #include

c++

if I choose gradYear = 2019 and currentYear = 2015, the below program doesnt work out well; it works fine for other conditions...

#include

using namespace std;

int main()

{

string name, status;

int gradYear, currentYear, difference, gradCurrent;

// User I/O

cout << "Please enter your name: ";

cin >> name;

cout << "Please enter your graduation year: ";

cin >> gradYear;

cout << "Please enter current year: ";

cin >> currentYear;

// Define status to output whether graduated/not/college year

gradCurrent = (currentYear + 4);

if (gradYear == currentYear) {

cout << " " << name << ", your status: graduated" << endl;}

else if (gradYear >= gradCurrent){

cout << " " << name << ", your status: not in college yet" << endl;}

else if (gradYear < currentYear) // Displays "graduated"

cout << " " << name << ", your status: graduated" << endl;

else if (gradYear > currentYear) // calculates college level

{

difference = gradYear - currentYear;

if (difference == 1)

status = "senior";

else if (difference == 2)

status = "junior";

else if (difference == 3)

status = "sophomore";

else if (difference == 4)

status = "freshman";

cout << " " << name << ", your status: " << status << endl;

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

Who was the first woman prime minister of india?

Answered: 1 week ago

Question

Explain the concept of going concern value in detail.

Answered: 1 week ago

Question

Define marketing.

Answered: 1 week ago

Question

What are the traditional marketing concepts? Explain.

Answered: 1 week ago