hi! I'm new in c++, can anyone give some instruction how I'll start this structure solution? if so, please give me some instruction

Problem given:

Define a structure called Toy with the following members:

. Name of Toy
. Price of Toy
. Made in (the place where the toy is made)
. Manufactured date (define as a structure with date, month, year)

Using the structure defined above, write a program that declares a variable of structure
Toy. Ask the user to enter the information of a toy. Then pass the variable to a function
to do the following:

. Check the manufactured date of the toy. If the date is before January 2012,
decrease 10% from the current price.
. Check the Made in information. If the toy is not made in Malaysia, then add
RM10.00 to the price.

Display the toy’s information in main(). Repeat for a new toy. Let the user chooses to
stop.

What part are you getting hung up on? Do you know how to create a struct?

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

struct Toy
{
string toyName;
double price;
string madeIn;
int d,m,y;
};

void input (Toy & to)
{
cout<<"Enter The Toy Information:\n"<<endl;
cout<<"Enter Name of Toy: "; cin>>to.toyname;
cout<<" Enter Price of Toy: "; cin>>to.price;
cout<<" Enter made in Place: "; cin>>to.madeIn;
cout<<"\n"<<endl;
cout<<"Manufactured Date Info"<<endl;
cout<<"Enter Day: "; cin>>to.d;
cout<<"Enter Month: "; cin>>to.m;
cout<<"Enter Year: "; cin>>to.y;

}
void Display (Toy to)
{
cout<<"Name of Toy:"<<to.toyName<<endl;
cout<<"Price of Toy: "<<to.price<<endl;
cout<<"Made In:"<<to.madeIn<<endl;
cout<<"Manufactured Date: "<<to.d <<"/"<<to.m<<"/"<<to.y<<"\n"<<endl;
}

int main ()
{
Toy to;
input (to);
display (to);

system ("pause");
return 0;
}

Inline Code Example Here

I can do only up to this. what chang do I need sir?

I hate to reiterate what Nathan already said but....what exactly are you stuck on?
Its hard to help you if you don't specify the problem.

Having said that I should point out that the above code already has mistakes -- did you know this?
e.g. line 16 should actually be:
cout<<"Name of Toy:"<<to.toyName<<endl; -- toyname is not a member of your struct but toyName is

In main you also call display() when in fact you should be calling Display() (unless you rename your function).

Also, if you read the requirements that you posted you will notice that the manufacture date should be a struct, hence your toy struct should contain another struct instead of the three ints that you are currently using.

For example:

struct Toy
{
    string toyName;
    double price;
    string madeIn;
    Date date;
};

Where Date is defined as:

struct Date
{
    int day;
    int month;
    int year;
};

Finally, you don't appear to have any validation at present is this what you need help with?

I've updated a bit in the previous coding for date that you mentioned. Now I need to do the validation for( date and madein). (1) to decrease 10% of price if date before January 2012 (2) to add 10 Rm if the madein country is Malaysia. stuck again!

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

struct Toy
{
string toyName;
double price;
string madeIn;

};

struct Date
  {
   int day;
   int month;
   int year;
   };

void input (Toy & to)
{
cout<<"Enter The Toy Information:"<<endl;
cout<<"***************************"<<endl;
cout<<"\n Enter Name of Toy: "; cin>>to.toyName;
cout<<" Enter Price of Toy: "; cin>>to.price;
cout<<" Enter made in Place: "; cin>>to.madeIn;
cout<<"\n"<<endl;
}
void input (Date & da)
{
cout<<"\nManufactured Date Info"<<endl;
cout<<"***********************"<<endl;
cout<<" Enter Day: "; cin>>da.day;
cout<<" Enter Month: "; cin>>da.month;
cout<<" Enter Year: "; cin>>da.year;

}
void display (Toy to)
{
cout<<"\n      Name of Toy: "<<to.toyName<<endl;
cout<<"     Price of Toy: "<<"RM "<<to.price<<endl;
cout<<"          Made In: "<<to.madeIn<<endl;

}

void Display (Date da)
{
   cout<<"\nManufactured Date: "<<da.day <<"/"<<da.month<<"/"<<da.year<<"\n"<<endl;
}
int main ()
{
Toy to;
input (to);
display (to);
Date da;
input (da);
Display (da);

system ("pause");
return 0;
}

Inline Code Example Here

Now I need to do the validation for( date and madein). (1) to decrease 10% of price if date before January 2012 (2) to add 10 Rm if the madein country is Malaysia. stuck again!

Why?

If you have a day, month and year what is stopping you from determining if it's before january 2012?..

You also have a "madeIn" member. Why can't you compare it's value with "malaysia" and act based on that?

I'm not sure if you are even trying..

I would like to mention a couple of things akashi:
1) When programming you really need to pay close attention to code that you are reading or writing -- The updated code that you have provided shows a new struct that can be used to represent a date, however, your Toy struct still doesn't contain a data member.

It should look more like:

struct Toy
{
string toyName;
double price;
string madeIn;
Date date;
};

2) If you are struggling to figure out how to write something in code it can very often be helpful to write down a solution in pseudo-code or plain English first and then convert to code after.

Finally, just in case you weren't already aware, DaniWeb isn't a place you should come to get someone else to do your work for you - You will never learn this way!
Instead, the forumns provide a way for you to get assistance when you are having problems or to get new ideas that may further your development skills.

Edit:
Once you have made an attempt at the validation, please post the code that you have produced yourself so that we can help you to resolve any issues.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.