Write a program that asks for the name of a pole vaulter and the dates and vault height (in meters) of the athlete's three best vaults. It should then report in order of the hieght (best first), the date on which each vault was made and its height.

Input Validation: Only accept values between 2.0 and 5.0 for the heights.

If someone could help me solve greatly appreciated. I have been doing C++ for only a few weeks in college so i am a little new and need to get a little help.

Recommended Answers

All 6 Replies

You will probably want to store the name as a string, the dates in one array, and the heights in another. Make sure the jump distance array is double or float. Then sort height list in ascending order, make sure that when you move a value in that array that you move it's cooresponding date.

We don't do people's homework for them. You write -- we will help. Post what you know how to do then ask questions about the parts you don't know how to do.

ok first time being here i'll come up with a code i think my only problem i am having is putting the dates and heights in order

You need to code a sort algorithm -- the easiest to code is the bubble sort. Search google for lots of example programs.

#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;

int main()
{
	char name[40];
	double vault1, vault2, vault3;
	char date1[40], date2[40], date3[40];

	// Name of pole vaulter
	cout << "What is the name of the pole vaulter? " << endl;
	cin.getline(name,40);

	// Month1, Vault1
	cout << "What was the month of the first pole vault? " << endl;
	cin.getline(date1,40);
	cout << "What was the height of the first pole vault? " << endl;
	cin >> vault1 ;

	// Month2, Vault2
	cout << "What was the month of the second pole vault? " << endl;
	cin.getline(date2,40);
	cout << "What was the height of the second pole vault? " << endl;
	cin >> vault2;

	// Month3, Vault3
	cout << "What was the month of the third pole vault? " << endl;
	cin.getline(date3,40);
	cout << "What was the height of the third pole vault? " << endl;
	cin >> vault3;

	system ("pause");
	return 0;
}

Ok i need the heights to be in order from highest to lowest with their date.

I am not sure how to do this if u can help thx (first time posting code hope it works properly)

commented: great going with the code tags :) +36

It will be a lot easier to sort if you put the dates and hights in arrays.

char dates[3][20];
float heighs[3];

The those prompts only have to be coded once inside a loop that counts from 0 to 3.

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.