Output is not displaying proper value

My code is working but, the output on the text file is not displaying proper value. What's wrong with my code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  #include <fstream>
#include <iostream>
#include <conio.h>
using namespace std;

void main()
{
	int repetitions, counter = 1, counter2 = 1;
	double starting_value, temp1, sequence, temp2, ave1, ave2;


	cout << "What is the starting value(Celsius) to be converted to Fahrenheit? ";
	cin >> starting_value;

	temp1 = starting_value;
	temp2 = starting_value;
	starting_value = temp1 * 9 / 5 + 32;

	cout << "What is the sequence after one another? ";
	cin >> sequence;

	cout << "How many repetitions would you like it to be? ";
	cin >> repetitions;

	ofstream experiment;
	experiment.open("experiment.txt", ios::out);
	experiment << temp1 << " " << char(186) << "Celsius \n";
	do
	{
		ave1 = temp1;
		temp1 += sequence;
		ave1 += temp1;
		experiment << temp1 << " " << char(186) << "Celsius \n";
		counter2++;
		if (counter2 == repetitions)
			ave1 /= counter2;
	} while (counter2 != repetitions);
	experiment << "Temperatures stored are: " << counter2 << endl;
	experiment << ave1;
	experiment.close();


	ofstream output;
	output.open("output.txt", ios::out);
	output << starting_value << " "<< char(186)<< "Fahrenheit \n";
	
	do
	{
		temp2 += sequence;
		starting_value = temp2 * (9 / 5) + 32;
		output << starting_value << " " << char(186) << "Fahrenheit \n";
		counter++;
	} while (counter != repetitions);

	output.close();



		_getch();
}
put on the text file is not displaying proper value.
Define "proper"
What it should display? What is it displaying now?
@micros24

It seems that you are not calculating Celsius to Fahrenheit, correctly. It should be..

starting_value = ((temp2 * 9.0) / 5.0) + 32;

Hope that is the problem you were having.

And one other thing. Put in a cout that shows the user the program is finished, and not just hung up.

1
2
3
4
5
output.close();

	cout << "Done..";

	int d=_getch();
Last edited on
Topic archived. No new replies allowed.