Jump to content

I would like some C++ help

ELSknutson

I have some C++ projects that I need to get done for a class I am in but I have little knowledge about C++ programming  and I could use some help.

Link to comment
Share on other sites

Link to post
Share on other sites

Help with what exactly? You posted a very vague topic so its is very difficult to give an answer that is worthwhile. Do you know any other languages? Do you know programming concepts? (E.G. Object oriented programming) It's like asking I am going to be mechanic but I don't know much about cars, can you help? Any extra information you can provide is necessary to answer your question. Also, the website Stack Overflow is a great resource to utilize.

Link to comment
Share on other sites

Link to post
Share on other sites

Help with what exactly? You posted a very vague topic so its is very difficult to give an answer that is worthwhile. Do you know any other languages? Do you know programming concepts? (E.G. Object oriented programming) It's like asking I am going to be mechanic but I don't know much about cars, can you help? Any extra information you can provide is necessary to answer your question. Also, the website Stack Overflow is a great resource to utilize.

Im in school for C++ programming. I took C programming like 3 years ago and do not renumber much about it  and I have 4 programs I need to wright  

 

1. Write C++ program that would ask you to enter a message, your program should echo back a message to the screen in the following format:  

Example: if you enter "C++ is fun"  your program should be C++ is fun.

 

2. write a C++ program that would define a structure called car; the structure should have four member variables, brand ,color, horsepower, and price.

define and object of type of car and call it my car, populate the members of your new structure from the keyboard interactively and finally print a report describing the car you create.

example "your car is a red toyota that can make 200 horsepower and has a pric of $22000

Link to comment
Share on other sites

Link to post
Share on other sites

Im in school for C++ programming. I took C programming like 3 years ago and do not renumber much about it  and I have 4 programs I need to wright  

 

1. Write C++ program that would ask you to enter a message, your program should echo back a message to the screen in the following format:  

Example: if you enter "C++ is fun"  your program should be C++ is fun.

 

2. write a C++ program that would define a structure called car; the structure should have four member variables, brand ,color, horsepower, and price.

define and object of type of car and call it my car, populate the members of your new structure from the keyboard interactively and finally print a report describing the car you create.

example "your car is a red toyota that can make 200 horsepower and has a pric of $22000

#include <iostream>#include <string>struct Car {	std::string Brand;	std::string Color;	int HorsePower;	float Price;};int main(){	Car myCar;	std::cout << "Brand: ";	std::cin >> myCar.Brand;	std::cout << "Color: ";	std::cin >> myCar.Color;	std::cout << "Horsepower: ";	std::cin >> myCar.HorsePower;	std::cout << "Price: ";	std::cin >> myCar.Price;	std::cout << "Your car is a " << myCar.Color << " " << myCar.Brand << " that can make " << myCar.HorsePower << " and has a price of " << myCar.Price << "$";	return 0;}

this is the second one, although it's pretty basic, put it in a loop for a better effect.

 

If you can't do the first one... you can stop wasting money on school (not to sound mean but it's true).

Link to comment
Share on other sites

Link to post
Share on other sites

#include <iostream>#include <string>struct Car {	std::string Brand;	std::string Color;	int HorsePower;	float Price;};int main(){	Car myCar;	std::cout << "Brand: ";	std::cin >> myCar.Brand;	std::cout << "Color: ";	std::cin >> myCar.Color;	std::cout << "Horsepower: ";	std::cin >> myCar.HorsePower;	std::cout << "Price: ";	std::cin >> myCar.Price;	std::cout << "Your car is a " << myCar.Color << " " << myCar.Brand << " that can make " << myCar.HorsePower << " and has a price of " << myCar.Price << "$";	return 0;}

this is the second one, although it's pretty basic, put it in a loop for a better effect.

 

If you can't do the first one... you can stop wasting money on school (not to sound mean but it's true).

 

I was useing them as an example but thank you  the one I most need help with is  this one 

Design a class and call it city: the class will have 3 private members as follows 

1- city name 

2- population

3- statename of type string

the class city should have 6 public members functions that will be gretters and setters of the object

example setcityname, setpopulation, setstatename 

get city name , get population, getstatename

 

inside main, instantiate an array of 3 objects called my cities. use a for loop to populat the object members, use another loo to print the output that will list all three cities  with name, population and the state the are in. 

Link to comment
Share on other sites

Link to post
Share on other sites

I was useing them as an example but thank you  the one I most need help with is  this one 

Design a class and call it city: the class will have 3 private members as follows 

1- city name 

2- population

3- statename of type string

the class city should have 6 public members functions that will be gretters and setters of the object

example setcityname, setpopulation, setstatename 

get city name , get population, getstatename

 

inside main, instantiate an array of 3 objects called my cities. use a for loop to populat the object members, use another loo to print the output that will list all three cities  with name, population and the state the are in. 

It's pretty basic, what's causing you a problem?

I can write it for you if you want but it's probably better if you make it on your own.

Link to comment
Share on other sites

Link to post
Share on other sites


#include <iostream>

#include <string>

class City

{

public:

void SetName(std::string name)

{

mCityName = name;

}

std::string GetName()

{

return mCityName;

}

void SetPopulation(unsigned int population)

{

mPopulation = population;

}

unsigned int GetPopulation()

{

return mPopulation;

}

void SetState(std::string state)

{

mStateName = state;

}

std::string GetState()

{

return mStateName;

}

private:

std::string mCityName;

unsigned int mPopulation;

std::string mStateName;

};

int main()

{

City cities[3];

std::string temp;

unsigned int popTemp;

for (int i = 0; i < 3; i++)

{

std::cout << "Enter city name: ";

std::cin >> temp;

cities.SetName(temp);

std::cout << "Enter population: ";

std::cin >> popTemp;

cities.SetPopulation(popTemp);

std::cout << "Enter state name: ";

std::cin >> temp;

cities.SetState(temp);

}

for each (City c in cities)

{

std::cout << "City name: " << c.GetName() << " Population: " << c.GetPopulation() << " State: " << c.GetState() << std::endl;

}

return 0;

}

Link to comment
Share on other sites

Link to post
Share on other sites

I wonder if this can even be called "projects".

Sounds like a homework question for me.

 

I don't think they were trying to hide that fact...

I have some C++ projects that I need to get done for a class

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×