Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,085 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,551 people online right now. Registration is fast and FREE... Join Now!




Please..I need a big help here..desperate..

 
Reply to this topicStart new topic

Please..I need a big help here..desperate.., To keep track of all cars on a used car lot.

lullaby dragon
14 Apr, 2008 - 10:19 AM
Post #1

New D.I.C Head
*

Joined: 12 Apr, 2008
Posts: 4

The information that he needs includes the type, seating capacity, price, miles per gallon, and color of each car. Define a struct named lotCar that will contain all of these members.

The program will allow user to input includes the type, seating capacity, price, miles per gallon, and color of each car. The input must be validated before writing the record to file:

- Valid car types are c-coupe, m-minivan and s-SUV and q-quit.
- The miles per gallon and price depend on the type of vehicle the user selects.
- Coupe - 25 mpg with cost of $15,000, 5 seat passengers
- Minivan - 20 mpg with a cost of $18,000, 5 seat passengers
- SUV - 18 mpg with a cost of 22,000, 7 seat passengers

Validate the type of car using Boolean function which will loop until a valid character has been entered. Return false when user enter 'q' and return true when user enter a valid car type. Another Boolean function to input the seating capacity the user selects. Allow users to continue working with the program but make a different choice if the seating capacity does not match the car they select.

Sample screen display:
Enter type of car : Šoupe, (m)inivan, (s)UV or (q)uit: c
Enter the seating capacity: 5
Enter miles per gallon: 25
Enter your color choice: green

Output file lotCar should resemble like this:
Coupe 5 25 green





So please help me, I am stuck with this coding for the problem:



CODE
#include <iostream>
#include <fstream>
#include <string>
using namespace std;


//define structure
struct lotCar
{
    char type;
    int seat_capacity;
    int miles;
    string color;
};


//function to input lotcar record
lotCar GetData()
{
    lotCar tempRec;
    cout << "Enter type of car: Šoupe, (m)inivan, (s)UV or (q)uit: ";
    cin >> tempRec.type;

    cout << "Enter the seating capacity that you want :";
    cin >> tempRec.seat_capacity;

    cout << "Enter miles per gallon : ";
    cin >> tempRec.miles;
    cout << "Enter your color choice : ";
    cin >> tempRec.color;
    return tempRec;
}


//function to display lotcar record
void ShowData (lotCar temp)
{
    char ans;

    switch (temp.type)
    {
        case 'C': case 'c':
            cout << "______________\n";
            cout << "\n type of car : coupe";
            cout << "\n seating capacity :5";
            cout << "\n miles per gallon :25";
            cout << "\n color :"<<temp.color;
            cout << "\n price : $15,000";
            cout << "\n_______________\n";
        break;
        case 'M': case 'm':
            cout << "______________\n";
            cout << "\n type of car : minivan";
            cout << "\n seating capacity :5";
            cout << "\n miles per gallon :20";
            cout << "\n color :"<<temp.color;
            cout << "\n price : $18,000";
            cout << "\n_______________\n";
        break;
        case 'S': case 's': case '7':
            cout << "______________\n";
            cout << "\n type of car : SUV";
            cout << "\n seating capacity :7";
            cout << "\n miles per gallon :18";
            cout << "\n color :"<<temp.color;
            cout << "\n price : $22,000";
            cout << "\n_______________\n";
    
        default:    //if character input do not match any cases above,do this:
            cout<<"Wrong selection\n\n";    //display-wrong menu selection
        }
    

    {    cout<<"\n\n do you want to quit?";//ask user whether to continue
        cin>>ans;    //input menu choice again
    }
    if (ans=='y'  || ans=='Y' );
    
        cout <<"thanks\n";

    else if

(ans=='n' || ans=='N' );
cout<< temp.type;
        
    };


//main program
int main()
{
    ofstream f_out("lotCar.txt",ios::app);
    lotCar your_record;

    your_record = GetData();
    ShowData (your_record);
    f_out<< "\t" << your_record.type<< "\t" <<your_record.seat_capacity<< "\t" <<your_record.miles<< "\t" <<your_record.color<<endl<<endl;
    f_out.close();

    return 0;
}



* so please help me thank you

*Mod Edit: added code tags: code.gif
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Please..I Need A Big Help Here..desperate..
14 Apr, 2008 - 11:00 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,198



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
What exactly would be your problem? If you can state what is wrong then we could narrow the response and get you up and working. smile.gif
User is offlineProfile CardPM
+Quote Post

lullaby dragon
RE: Please..I Need A Big Help Here..desperate..
14 Apr, 2008 - 11:30 AM
Post #3

New D.I.C Head
*

Joined: 12 Apr, 2008
Posts: 4

QUOTE(Martyr2 @ 14 Apr, 2008 - 12:00 PM) *

What exactly would be your problem? If you can state what is wrong then we could narrow the response and get you up and working. smile.gif


I want the real coding for the problems..
because my solution is really not working at all..


User is offlineProfile CardPM
+Quote Post

Nykc
RE: Please..I Need A Big Help Here..desperate..
14 Apr, 2008 - 11:44 AM
Post #4

sudo rm -R /
Group Icon

Joined: 14 Sep, 2007
Posts: 4,132



Thanked: 16 times
Dream Kudos: 275
My Contributions
I think what Martyr2 means is:

What kind of errors are you getting?
What are the results you are receiving? What should the results be?

What is the nature of your problem, you state it isn't working...
What is not working.


User is online!Profile CardPM
+Quote Post

lullaby dragon
RE: Please..I Need A Big Help Here..desperate..
14 Apr, 2008 - 11:56 AM
Post #5

New D.I.C Head
*

Joined: 12 Apr, 2008
Posts: 4

I think that all of it in the coding that seems to be the problem

The error is that
there is empty statement found..

at the quit section

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 08:06PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month