Can someone please help me out here. i'v got an assignment to finish up on C++ and it just doesnt run properly. its a care hiring program that asks for details and prints it out at the end. when i enter my house number, address, and phone number it just goes loco. Help will be greatly appreciated. here's the code:
#include <iostream>
#include <cstdlib>
#include <string>
#include <cmath>
void line ();
using namespace std;
// Function for car choice
void carchoice ()
{
do { // Start of loop
cout << "\n\t\t\t\tCARS FOR HIRE\n\n\n\tProduct Code\t\tItem Description\tCost Per Day\n";
line ();
cout << "\n\n\tA\t\t\tNissan\t\t\t$7.00\t\t";
cout << "\n\n\tB\t\t\tFord Focus\t\t$7.00\t\t";
cout << "\n\n\tC\t\t\tPeugeot 107\t\t$9.00\t\t";
cout << "\n\n\tD\t\t\tVolvo V40\t\t$7.00\t\t";
cout << "\n\n\tE\t\t\tVolksWagon\t\t$7.50\t\t";
cout << "\n\n\n\tEnter choice of vehicle you wish to hire. (A, B, C, D or E):";
cin >> choice;
// Switch case statement
switch (choice)
{
case 'A':
case 'a':
cout<< "\n\tYou selected Nissan\n\t" << endl;
price = 7.00;
break;
case 'B':
case 'b':
cout<< "\n\tYou selected Ford Focus\n\t" << endl;
price = 7.00;
break;
case 'C':
case 'c':
cout<< "\n\tYou selected Peugeot 107\n\t" << endl;
price = 9.00;
break;
case 'D':
case 'd':
cout<< "\n\tYou selected Volvo V40\n\t" << endl;
price = 7.00;
break;
case 'E':
case 'e':
cout<< "\n\tYou selected VolksWagon\n\t" << endl;
price = 7.50;
break;
default:
cout << "\n\tThe choice of vehicle can not be found!\n\t"<<endl;
break;
}
cout << "\tEnter number of days you wish to hire it for. ";
cin >> numdays;
cost = price*numdays;
cout << "\n\tThe cost of hire for this car is "<<char(156)<< cost << endl;
cout << "\n\tDo you wish to hire this car at this rate? (Y/N): ";
cin >> option;
system ("cls");
// Entry of neither "y" or "Y" will initiate loop
}while (option != 'Y' && option != 'y');
system("cls");
cin.get();
}
// function for entry of customer details
void customerdetails (char name[],char surname[],int addressn,
char adres[],char PNum[])
{
cout << "\nEnter first name: "; //Print out
cin >> name; // input
cout << "\nEnter surname name: ";
cin >> surname;
cout << "\nEnter house number: ";
cin >> addressn;
cout << "\nEnter your address: ";
cin >> adres;
cout << "\nPlease enter Phone Number: ";
cin >> PNum;
cout << "\n\tYour invoice will now be displayed\n"<< endl;
system("pause");
}
// Main Function
int main ()
{
using namespace std;
char name[50], surname[50], adres[50], PNum[50];
int addressn;
system ("color f6"); // System Colour
carchoice (); // Call up carchoice function#
cout << "\n\t\t\tHire and Personal Details Form\t\t\n\n";
// Call up customer details function
customerdetails (name,surname,addressn,adres,PNum);
cout << "\n\n\tVehicle Type: ";
//If,else statement to display the the car that user has selected in the invoice
if (choice == 'a' || choice == 'A' )
{ cout << "Nissan" << endl; }
1) use code tags to show code. They looks like <>
2) What do you mean "Not working properly"? Can you show input you are trying to enter, what you expect and what is happening.