Hey, sorry if this is already posted somewhere, I did a cursory glance over and saw nothing, so here I am.
I'm writing the second draft of a program I'm trying to make to keep a tally of sales my company's had over the last two months, and I think I'm doing alright so far, but I'm running into a complication with IF/ELSE statements in reference to CHAR inputs.
It debugs fine, but whenever I go to enter the month(June or July)it runs the "else" condition to terminate the program.
Here's the code:
Code:
/* First Draft Program for June/July Sales */
#include <iostream>
using namespace std;
int julydeliveries = 5463;
int julycpus = 1212;
int julyrepairs = 768;
int julytotals = julydeliveries + julycpus + julyrepairs;
int junedeliveries = 2352;
int junecpus = 1256;
int junerepairs = 247;
int junetotals = junedeliveries + junecpus + junerepairs;
int main()
{
char month [5];
cout << "Totals for: ";
cin >> month;
if (month == "june")
{
cout << "Deliveries: " << junedeliveries << "\n\n";
system("pause");
cout << "\n\nCustomer Pick-ups: " << junecpus << "\n\n";
system("pause");
cout << "\n\nRepairs: " << junerepairs << "\n\n";
system("pause");
cout << "\n\nTotal Sales: " << junetotals;
cout << "\n\n";
}
else if (month == "july")
{
cout << "Deliveries: " << julydeliveries <<"\n\n";
system("pause");
cout << "\n\nCustomer Pick-ups: " << julycpus << "\n\n";
system("pause");
cout << "\n\nRepairs: " << julyrepairs << "\n\n";
system("pause");
cout <<"\n\nTotal Sales: " << julytotals;
cout << "\n\n";
}
else
{
cout << "You must enter either June or July! Terminating Program!\n\n";
}
system("pause");
return 0;
}
And, here's the outcome:
Code:
Totals for: June
You must enter either June or July! Terminating Program!
Press any key to continue . . .
Thanks, in advance!