class Museum {
public:
void UsernamePassword();
void openFile();
void Counter();
}museo;
#endif
using namespace std;
struct money {
int kid;
int student;
int ID;
int adult;
int sc;
int kidcounter;
int studentcounter;
int idcounter;
int adultcounter;
int sccounter;
}rates;
int main() {
rates.kid=60;
rates.ID=54;
rates.student=60;
rates.adult=100;
rates.sc=80;
museo.UsernamePassword();
system("cls");
cout << "This is a Museum Ticket Counter\n"
<< "Reminders: Please input 'END' to go the next day\n"
<< "Here are the rates of the each division in age: \n"
<< "Kid/Toddler (Ages 1 to 10 years old)- Php60.00\n"
<< "Student - Php 60.00\n"
<< "Student (with current ID)- Php 54.00\n"
<< "Adult (Ages 19 to 64 years old)- Php 100.00\n"
<< "Senior Citizen (Ages 65 and above)- Php 80.00";
system("pause>0"); system("cls");
museo.Counter();
system("pause>0");
return 0;
}
void Museum::openFile() {
ofstream DataOutput;
DataOutput.open("file.txt", ios_base::app);
DataOutput << "Kids: " << rates.kidcounter << endl
<< "Students (without ID): " << rates.studentcounter << endl
<< "Students (with ID): " << rates.idcounter << endl
<< "Adults: " << rates.adultcounter << endl
<< "Senior Citizens: " << rates.sccounter << endl;
DataOutput.close();
}
void Museum::UsernamePassword() {
string newpassword;
int charLimit=20;
int n = 0;
char *pass = new char[20];
char character;
char username[100];
cout << "Username: ";
cin >> username[100];
cout << "Password: ";
do
{
character = _getch();
if (character == 8 && n >= 0)
{ // 1) priority: erase when backspace
if (n != 0)
{ // erase only if 1-more characters
cout << "\b \b";
n--;
} // else do nothing
}
else if (character == 13 && (n > 0 && n <= charLimit))
break; // 2) priority: accept intput when 1-20 characters
else if (n >= charLimit)
{ // 3) priority: when there are more than 20 characters
if (character == 13)
{ // once enter is pressed, prompt user else proceed
delete[]pass;
pass = new char[charLimit];
n = 0;
cout << "\n\t /!\\ Password has exceeded 20 characters. Please enter a new one.\n";
cout << "\tPassword: ";
}
}
if (character != 13 && character != 8)
{ // when input is not a special key
if (n < charLimit) // store when characters 1-20
pass[n] = character;
cout << "*"; // output asterisks and increment n regardless
n++;
}
} while (true);
// this flow will allow the user to input any # of characters
// but the program will ignore characters beyond the specified limit.
// still, asterisks will be displayed regardless of the character limit.
// the program will only prompt the user if the enter key was pressed.
cout << endl;
//to turn array of characters into string
for (int x = 0; x <= n - 1; x++)
newpassword += pass[x];
delete[]pass;
// return newpassword;
}
my problem is way down in the last function
The cin>>KID; is not being processed by the compiler, only the other cin's except this one
Is there any way to resolve this?
#include <iostream>
#include <string>
#include <conio.h>
#include <fstream>
#ifndef MUSEUM_H
#define MUSEUM_H
//header files
class Museum {
public:
void UsernamePassword();
void openFile();
void Counter();
}museo;
//class declaration
#endif
using namespace std;
struct money {
int kid;
int student;
int ID;
int adult;
int sc;
int kidcounter;
int studentcounter;
int idcounter;
int adultcounter;
int sccounter;
}rates;
//structure declaration
int main() {
rates.kid=60;
rates.ID=54;
rates.student=60;
rates.adult=100;
rates.sc=80;
//declaration of rates
museo.UsernamePassword(); //calling of the UsernamePassword function
system("cls");
cout << "This is a Museum Ticket Counter\n"
<< "Reminders: Please input 'END' to go the next day\n"
<< "Here are the rates of the each division in age: \n"
<< "Kid/Toddler (Ages 1 to 10 years old)- Php60.00\n"
<< "Student - Php 60.00\n"
<< "Student (with current ID)- Php 54.00\n"
<< "Adult (Ages 19 to 64 years old)- Php 100.00\n"
<< "Senior Citizen (Ages 65 and above)- Php 80.00";
system("pause>0"); system("cls");
museo.Counter();//calling the function Counter
system("pause>0");
return 0;
}
void Museum::openFile() {
ofstream DataOutput;
DataOutput.open("file.txt", ios_base::app);
DataOutput << "Kids: " << rates.kidcounter << endl
<< "Students (without ID): " << rates.studentcounter << endl
<< "Students (with ID): " << rates.idcounter << endl
<< "Adults: " << rates.adultcounter << endl
<< "Senior Citizens: " << rates.sccounter << endl;
DataOutput.close();
} //function for making a file and storing the data
My problem is within the last function
the "cin >> KID;"
I've been searching for the past few hours but still haven't gotten a correct answer to get this fixed
Because every time i compile the codes, this line isn't executing
how do i resolve this problem?
It's just like a pass-through
"cout << "Kids" << endl;" is being read then directly runs "cout << "Student (without ID) \n"; cin >> STUDENT;" but not running "cin >> KID;"
*the program isn't asking for my input for the number of kids