SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 6 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 16 Nov 2017 My Price 10.00

debug this code for visual studio 2017 for C++.

Looking for help to debug this code for visual studio 2017 for C++. I have attached an example of my previous code which is labeled calendar(1). The file attached called TemplateForProjSix is the main file. I just need help debugging this code and help to answer the questions within. There is a sample run pdf attached also. I will add a few details from the previous project below. Thank you.

 

 

 

Century Value: This function should take the first two digits of the year(that is, the century), divide by 4, and save the remainder. Subtract the remainder from 3 and return this value multiplied by 2. For example, the year 2008 becomes (20/4)=5 with a remainder of 0. 3-0=3. Return 3*2=6

 

Year Value: This function computes a value based on the years since the beginning of the century. First, extract the last two digits of the year. For example, 08 is extracted for 2008. Next, factor in leap years. Divide the value from the previous step by 4 and discard the remainder. Add the two results together and return this value. For example, from 2008 we extract 08. Then (8/4)=2 with a remainder of 0. Return 2+8 =10

 

Month Value: Follow this chart

January Return Value: 0 (6 if year is a leap year)

February Return Value: 3 (2 if year is a leap year)

March Return Value: 3

April Return Value: 6

May Return Value: 1

June Return Value: 4

July Return Value: 6

August Return Value: 2

September Return Value: 5

October: Return Value: 0#include <iostream>
#include <cstring>

using namespace std;

void testMenu();
bool isLeapYear(int year);
int getCenturyValue(int year);
int getYearValue(int year);
int getMonthValue(int month, int year);
int dayOfWeek(int month, int day, int year);
string dayOfWeek(int day);

int main()
{
    int choice;
    int day, month, year;
    do{
        testMenu();
        cout<<"Please choose from menu: ";
        cin>>choice;
        switch(choice)
        {
            case 1:    
                cout<<"Please enter a year! ";
                cin>>year;
                if(isLeapYear(year))
                    cout<<"Year "<< year <<" is a leap year"<<endl;
                else
                    cout<<"year"<<year<<" is NOT a leap year"<<endl;
                break;
            case 2:
                cout<<"Please enter a year! ";
                cin >> year;
                cout <<"The century value is: "<<getCenturyValue(year)<<endl;
                break;
            case 3:
                cout<<"Please enter a year! ";
                cin >> year;
                cout<<"The year value is: "<<getYearValue(year)<<endl;
                break;
            case 4:
                cout<<"Please enter a year and month: ";
                cin>>year>>month;
                cout<<"The month value is: "<<getMonthValue(month,year)<<endl;
                break;
            case 5:
                cout<<"Please enter a year, a month, and a day: ";
                cin>>year>>month>>day;
                cout<<"The day of the week is: "<<dayOfWeek(month,day,year)<<endl;
                break;
            case 6:
                cout<<"Please enter a day of the week(0 for Sunday, 1 for Monday, etc): ";
                cin>>day;
                cout<<"The name of the day of the week is: "<<dayOfWeek(day)<<endl;
                break;
            case 7:
                cout<<"Did you tested all functions yet? If not, please rerun the program\n"
                break;
            default:
                cout<<"Wrong option. Please choose from menu\n";
                break;
        }
        system("pause");
    }while(choice!=7);
    return 0;
}

int getMonthValue(int month, int year)
{
    int months[]={11,12,1,2,3,4,5,6,7,8,9,10};
    double val=(2.6*(months[month-1]))-0.2;
    int result=(int)floor(val);
    return result%7;
}
int getYearValue(int year)
{
    double val=(year%100)/4;
    int temp=(int)floor(val);
    int result=(year%100)+temp;
    return result%7;
}

int getCenturyValue(int year)
{
    int c=year/100;
    int value;
    switch(c){
        case 17:
            value=4;
            break;
        case 18:
            value=2;
            break;
        case 19:
            value=0;
            break;
        case 20:
            value=6;
            break;
        case 21:
            value=4;
            break;
        case 22:
            value=2;
            break;
        case 23:
            value=0;
            break;
    };
    return value;
}
int dayOfWeek(int month, int day, int year)
{
    static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
    year -= month < 3;
    return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7;
}
string dayOfWeek(int day)
{
    string dayName[7]={    "Sunday",
                        "Monday",
                        "Tuesday",
                        "Wednesday",
                        "Thursday",
                        "Friday",
                        "Saturday"
    };
    return dayName[day];
}
void testMenu()
{
    cout<<"*************************************\n";
    cout<<"*           Test Menu               *\n";
    cout<<"* 1. isLeapYear                     *\n";
    cout<<"* 2. getCenturyValue                *\n";
    cout<<"* 3. getYearValue                   *\n";
    cout<<"* 4. getMonthValue                  *\n";
    cout<<"* 5. dayOfWeek(month, day, year)    *\n";
    cout<<"* 6. dayOfWeek(day)                 *\n";
    cout<<"* 7. Quit                           *\n";
    cout<<"*************************************\n";
}
bool isLeapYear(int year)
{
    
    if ( ((year % 4 == 0) && (year % 100 != 0)) || ( year % 400 == 0))
        return true;
    else
        return false;
}

November: Return Value: 3

December: Return Value 5

Attachments:

Answers

(5)
Status NEW Posted 16 Nov 2017 01:11 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)