I'm taking a computer science class and I have to write 3 programs in C++. My problem is I don't know how to get started when trying to solve these 3 problems. Is there anyone there that can help. Once I know who can help I'll let you know what the 3 programs I have to write are.
the problems i have are how to calculate the number of days between two dates including leap year, writing a program for the game Nim where computer plays against human opponent, and the other one is calculating the sum of every other digit with a long number given
this is what ive done so far but the program isnt working
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int getDays(int month);
int getInteger;
void main ()
{
int MonthDays; // equal to the total number of days from the past months combined.
int Day; // used to enter a specific day of the month (i.e. the 22nd or 3rd)
int Choice; // Used to select from the switch statement
int Date1, Date2;
//Displays the months user will choose from and input
cout << "1." << " January ";
cout << "\t\t2." << setw (4) << " February" << endl;
cout << "3." << " March ";
cout << "\t\t4." << setw (4) << " April " << endl;
cout << "5." << " May ";
cout << "\t\t\t6." << setw (4) << " June " << endl;
cout << "7." << " July " ;
cout << "\t\t8." << setw (4) << " August " << endl;
cout << "9." << " September " ;
cout << "\t\t10." << setw (4) << " October " << endl;
cout << "11." << " November " ;
cout << "\t\t12." << setw (4) << " December " << endl;
cout << "\nEnter the month of the first date: ";
Choice = getInteger();
MonthDays = getDays(Choice);
cout << "Enter the day of the month: ";
Day = getInteger();
Date1 = MonthDays + Day;
cout << "Days: " << Date1 << "\n\n"; // Displays the total number of days for date1
// Stops Retrieving the info for the first date
// Retrieving the info for the second date starts here
cout << "Enter the month for the second date: ";
Choice = getInteger;
MonthDays = getDays(Choice);
cout << "Enter the day of the month: ";
Day = getInteger;
Date2 = MonthDays + Day;
cout << "Days: " << Date2 << "\n\n";
cout << "The number of days between the two dates is: " << abs(Date1 - Date2) << endl;
}
int getDays(int month){
int sum = 0;
int days = 0;
for (int cnt = 1; cnt < month; cnt++){
switch(cnt){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days = 31;
break;
case 2:
days = 28;
break;
case 4:
case 6:
case 9:
case 11:
days = 30;
break;
}
sum += days;
}
return sum;
}