-
-
Save rhysforyou/2780529 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Name: Anthony Burchell-Bailey | |
Lab: 8:30-10:30 17-106 | |
Modifcation Date: //2012 | |
File Description: Lab week 12 task 5 | |
*/ | |
#include <iostream> | |
using namespace std; | |
struct car | |
{ | |
char make[21]; | |
char model[21]; | |
int year; | |
long price; | |
}; | |
void finalinput(car &inputCar); | |
int pricefind(car[]); | |
int main() | |
{ | |
int largest; | |
car carinstock[5] = {{"Toyota", "Camry", 2002, 23290}, | |
{"Holden", "Barina", 2001, 11000}, | |
{"Mazda", "Astina", 1993, 8200}, | |
{"Ford", "Fairmont", 1995, 8500}}; | |
finalinput(carinstock[4]); | |
largest = pricefind(carinstock); | |
cout << "Make: " << carinstock[largest].make << endl << | |
"Model: " << carinstock[largest].model << endl << | |
"Year: " << carinstock[largest].year << endl << | |
"Price: " << carinstock[largest].price << endl; | |
return 0; | |
} | |
void finalinput(car &inputCar) | |
{ | |
cout << "Enter car make\n"; | |
cin >> inputCar.make; | |
cout << "Enter car model\n"; | |
cin >> inputCar.model; | |
cout << "Enter car year\n"; | |
cin >> inputCar.year; | |
cout << "Enter car price\n"; | |
cin >> inputCar.price; | |
} | |
int pricefind(car carinstock[]) | |
{ | |
int largest = 0; | |
for (int i = 1; i < 5; i++) | |
{ | |
if (carinstock[largest].price < carinstock[i].price) | |
largest = i; | |
} | |
return largest; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment