Home > Back-end >  This also can not find out several errors
This also can not find out several errors

Time:10-03

# include & lt; String>
# include
using namespace std;
# include

Const int the Password=13002506;

Typedef struct Node
{
Int no;
Char owner [20].//to the owner as a cashier write
Int kind;//vehicle type 1, 2, 3 digital input;
Float journey;//if the input is 1, 2, 3, to join the journey to calculate, # define journey for jour
Float money;
Struct Node * next;
} Cars;
Int pass ()
{
Int count, pw.

Count=0;
While (the count & lt; 3)
{
coutcout<& lt;" Please input password: operation ";
cin> Pw.
If (pw!=Password)
{
count++;
cout<& lt;" Operating password mistake!" }
The else
{
break;
}
}
If (count==3)
{
count=0;
}
The else {
count=1;
}

Return the count.
}

Int menu ()
{
Int selected;

While (true)
{
coutcout<& lt;" 1. Please enter the model: "& lt; cout<& lt;" 2. Please enter a way: "& lt; cout<& lt;" 3. The calculated capture to expend: "& lt; cout<& lt;" 4. Vehicle information display: "& lt; cout<& lt;" 0. Exit the program "& lt;
cout<& lt;" Please enter your choice: (0 ~ 4) ";
cin> Selected;

If (selected & gt; 4 | |
Selected & lt; 0)
{
cout<& lt;" Input error, please input again!" }
The else
{
break;
}
}

Return selected;
}

Void input (int & amp; O, n, char * int & amp; K, float & amp; J)
{
coutcout<& lt;" 1. Please enter the vehicle number: ";
cin> n;//this is with reference to change the function of the
cout<& lt;" 2. Please enter a cashier's name: ";
cin> o;
cout<& lt;" 3. Please enter the vehicle type: ";
cin> k;
cout<& lt;" 4. Please enter the travel: ";
cin> j;
Float calCharge (float journey)
{

Float money;

Money=0;
If (kind=1)
{
Money=journey * 0.5;
}

If (kind=2)
{
Money=journey * 0.4;
}

If (kind=3)
{
Money=journey * 0.3;
}


Return money.
}
Int main (int arg c, char * argv [])
{
Int selected;
Head Cars * and * s;

The head=new Cars ();
The head - & gt; Next=NULL;

cout<& lt;" Welcome to use the highway billing system!"
if (! Pass ())
{
cout<& lt;" Do you have contact three input error! System is... "& lt; system("pause");
return 0;
}

While (true)
{
The switch (selected=menu ())
{
Case 1:
S=new Cars ();//system in the beginning, on the left side, habitual writing order, not follow one's inclinations of programming
The input (s - & gt; No, s - & gt; The owner, s - & gt; Kind, s - & gt; Journey);
S - & gt; Next=head - & gt; Next;
The head - & gt; Next=s;
break;

Case 2:
S=head - & gt; Next;
While (s)
{
S - & gt; Money=calCharge (s - & gt; Journey);
S=s - & gt; Next;
}
Cout & lt; <"Billing to complete" & lt; break;

Case 3:
S=head - & gt; Next;
Printf (" print vehicle information: \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" number charge staff car journey cost \ n ");
While (s)
{
Printf (" % - 10 - - 10 16 s % d % d % 10.2 f % 10.2 f \ n ",
S - & gt; No, s - & gt; The owner, s - & gt; Kind, s - & gt; Journey, s - & gt; Money);
S=s - & gt; Next;
}
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
break;

Default:
break;
}

If (selected==0)
{
cout<& lt;" Welcome to use! Goodbye..." break;
}
}

system("pause");
cout<& lt;" Please type the command identifier: ";
Char chCmd [256]={0};//define a character array
While (true)
{
Cin. Getline (chCmd, 255);//wait for input from the user
If (chCmd [0]=='? ')
{
//output help information
cout<& lt;" Input number 1 shows system time, figure 2 shows the system date, enter the letter e log out!" }
Else if (chCmd [0]=='e')
{
return 0;
}
Else if (chCmd [0]=='1')
{
Time_t nowTime;
Time (& amp; NowTime);//get the system time
* sysTime struct tm=localtime (& amp; NowTime);//convert the system time
cout<& lt;" The system time: "& lt;
}
Else if (chCmd [0]=='2')
{
Time_t nowTime;
Time (& amp; NowTime);//get the system time
* sysTime struct tm=localtime (& amp; NowTime);//convert the system time
cout<& lt;" The system time: "& lt; <1900 + sysTime - & gt; Tm_year & lt; & lt;" - "& lt;
SysTime - & gt; Tm_mon + 1 & lt; & lt;" - "& lt; }
cout<& lt;" Please type the command identifier: "& lt; }

return 0;
}

CodePudding user response:

Is a little ugly, also please mo

CodePudding user response:

Void input (int & amp; O, n, char * int & amp; K, float & amp; J)
{
coutcout<& lt;" 1. Please enter the vehicle number: ";
cin> n;//this is with reference to change the function of the
cout<& lt;" 2. Please enter a cashier's name: ";
cin> o;
cout<& lt;" 3. Please enter the vehicle type: ";
cin> k;
cout<& lt;" 4. Please enter the travel: ";
cin> j;//here less}
nullnullnullnullnullnullnullnullnullnullnullnull
  • Related