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

int main()
{
	char name[40];
	double date1;
	double date2;
	double date3;
	double h1;
	double h2;
	double h3;
	

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

	// Month1, Vault1
	cout << "What was the date of the first pole vault using ddmmyy? ";
	cin >> date1;
	cout << "What was the height of the first pole vault? ";
	cin >> h1;
	
	// Month2, Vault2
	cout << "What was the date of the second pole vault using ddmmyy? ";
	cin >> date2;
	cout << "What was the height of the second pole vault? ";
	cin >> h2;
	
	// Month3, Vault3
	cout << "What was the date of the third pole vault using ddmmyy? ";
	cin >> date3;
	cout << "What was the height of the third pole vault? ";
	cin >> h3;

	// Calculates the highest pole vault height first and last the lowest pole vault height 
	if ((h1 > h2) && (h2 > h3))
	cout << h1 << "\t" << date1 << endl << h2 << "\t" << date2 << endl << h3 << "\t" << date3 << endl;
	if ((h1 > h3) && (h3 > h2))
	cout << h1 << "\t" << date1 << endl << h3 << "\t" << date3 << endl << h2 << "\t" << date2 << endl;
	if ((h2 > h1) && (h1 > h3))
	cout << h2 << "\t" << date2 << endl << h1 << "\t" << date1 << endl << h3 << "\t" << date3 << endl;
	if ((h2 > h3) && (h3 > h1))
	cout << h2 << "\t" << date2 << endl << h3 << "\t" << date3 << endl << h1 << "\t" << date1 << endl;
	if ((h3 > h1) && (h1 > h2))
	cout << h3 << "\t" << date3 << endl << h1 << "\t" << date1 << endl << h2 << "\t" << date2 << endl;
	if ((h3 > h2) && (h2 > h1))
	cout << h3 << "\t" << date3 << endl << h2 << "\t" << date2 << endl << h1 << "\t" << date1 << endl;
	

	system ("pause");
	return 0;
}

The problem i am having is I have to have the heights be only 1 decimal to the right whatever your put in for instance: 55.0 4.0 i just do not know how to make just the heights 1 decimal i tried cout << fixed << setprecision(1); but that makes the dates 1 decimal too if you understand what i am trying to please help.

I am trying to make just the heights 1 decimal Ex: 4.0 3.0 55.0

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

int main()
{
	char name[40];
	double date1;
	double date2;
	double date3;
	double h1;
	double h2;
	double h3;
	

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

	// Month1, Vault1
	cout << "What was the date of the first pole vault using ddmmyy? ";
	cin >> date1;
	cout << "What was the height of the first pole vault? ";
	cin >> h1;
	
	// Month2, Vault2
	cout << "What was the date of the second pole vault using ddmmyy? ";
	cin >> date2;
	cout << "What was the height of the second pole vault? ";
	cin >> h2;
	
	// Month3, Vault3
	cout << "What was the date of the third pole vault using ddmmyy? ";
	cin >> date3;
	cout << "What was the height of the third pole vault? ";
	cin >> h3;

	// Calculates the highest pole vault height first and last the lowest pole vault height 
	if ((h1 > h2) && (h2 > h3))
	cout << h1 << "\t" << date1 << endl << h2 << "\t" << date2 << endl << h3 << "\t" << date3 << endl;
	if ((h1 > h3) && (h3 > h2))
	cout << h1 << "\t" << date1 << endl << h3 << "\t" << date3 << endl << h2 << "\t" << date2 << endl;
	if ((h2 > h1) && (h1 > h3))
	cout << h2 << "\t" << date2 << endl << h1 << "\t" << date1 << endl << h3 << "\t" << date3 << endl;
	if ((h2 > h3) && (h3 > h1))
	cout << h2 << "\t" << date2 << endl << h3 << "\t" << date3 << endl << h1 << "\t" << date1 << endl;
	if ((h3 > h1) && (h1 > h2))
	cout << h3 << "\t" << date3 << endl << h1 << "\t" << date1 << endl << h2 << "\t" << date2 << endl;
	if ((h3 > h2) && (h2 > h1))
	cout << h3 << "\t" << date3 << endl << h2 << "\t" << date2 << endl << h1 << "\t" << date1 << endl;
	

	system ("pause");
	return 0;
}

The problem i am having is I have to have the heights be only 1 decimal to the right whatever your put in for instance: 55.0 4.0 i just do not know how to make just the heights 1 decimal i tried cout << fixed << setprecision(1); but that makes the dates 1 decimal too if you understand what i am trying to please help.

I am trying to make just the heights 1 decimal Ex: 4.0 3.0 55.0

You shouldn't be reading in the data into a double or an integer in ddmmyy format anyway. What happens when the date is entered as 061008, which is today's date? That leading 0 is dropped in the output. If you store the date as an integer or a string, fixed << setprecision (1) won't have an effect. A date really isn't a double anyway, so store it as a string.

ty i got it now

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.