#include <iostream.h>
#include <math.h>
#include <stdlib.h>
#include <fstream.h>
#include <iomanip.h>
#include <string.h>
#include <ctype.h>
void head_title_name();//head_title_name function
void read_input();//read_input function
void dayenter();//calc_info function
void tempcalc();//results function
void do_again();//do_again function
int i,j,k,m;//declare as variables
int temp[10][3];//multi dimensional array
int num;
char y_n;//declare as variable
ofstream outfile;//enables outfile
ofstream infile;//enables infile
setw();//enables setw
void main()//main function
{
head_title_name();
}//end function
void head_title_name()
{
cout << "C++ Organizer: Josh Rivera 'aka' sloth
";
cout << "Class: Computer Science, RRHS
";//introduces program
cout << "Instructor: Mr H, Block 4
";
cout << "Program #6: Celsius-Farenheit Conversion
";
do_again();
}//end function
void do_again()
{
cout << "
Would you like to enter 7 day values?
";//prompts user
cout << "Press Y for Yes or N for No and press enter to continue
";
cin >> y_n;
system("cls");
switch (y_n)
{case 'No':
case 'NO':
case 'no'://no answer
case 'N'://capital N anser
case 'n'://lower case n answer
system("cls");
cout << "Thank You
";
break;
case 'YES':
case 'Yes':
case 'yes'://yes answer
case 'Y'://capital Y answer
case 'y'://lowercase y answer
cout << "Thank You for playing
";
dayenter();
break;
default:
cout << "Please read and follow all directions
";//if directions aren't followed
do_again();
break;}
}//end function
void dayenter()
{
outfile.open("outprogram3", ios::out);//opens outfile
//enter:
cout << "Please enter the value for day #1 ";
cin >> temp[i][0];
cout << "Please enter the value for day #2 ";
cin>> temp[i][1];
cout << "Please enter the value for day #3 ";
cin>> temp[i][2];
cout << "Please enter the value for day #4 ";
cin>> temp[i][3];
cout << "Please enter the value for day #5 ";
cin>> temp[i][4];
cout << "Please enter the value for day #6 ";
cin>> temp[i][5];
cout << "Please enter the value for day #7 ";
cin>> temp[i][6];//if ((tri[i][0]<=0) || (tri[i][1]<=0) || (tri[i][2]<=0))
//{cout << "Cannot have a negative measurement or a measurement equal to 0
";//no 0's or negative numbers
//goto enter;
system("cls");//clears screen
cout << "
Day # Celsius Reading Farenheit Reading
";//begin chart
cout << " ----- --------------- -----------------
";
outfile << " Day # Celsius Reading Farenheit Reading
";
outfile << " ----- --------------- -----------------
";
tempcalc();//calls tri_measure
}//endfunction
void tempcalc()
{
cout << "Day #1:"<<temp[i][0]<<setw(16)<<(((temp[i][0]-32)/9)*5)<<setw(25)<<(((temp[i][0]*9)/5)+32)<<'
';
outfile << "Day #1:"<<temp[i][0]<<setw(16)<<(((temp[i][0]-32)/9)*5)<<setw(10)<<(((temp[i][0]*9)/5)+32)<<'
';
cout << "Day #2:"<<temp[i][1]<<setw(16)<<(((temp[i][1]-32)/9)*5)<<setw(25)<<(((temp[i][1]*9)/5)+32)<<'
';
outfile << "Day #2:"<<temp[i][1]<<setw(16)<<(((temp[i][1]-32)/9)*5)<<setw(10)<<(((temp[i][1]*9)/5)+32)<<'
';
cout << "Day #3:"<<temp[i][2]<<setw(16)<<(((temp[i][2]-32)/9)*5)<<setw(25)<<(((temp[i][2]*9)/5)+32)<<'
';
outfile << "Day #3:"<<temp[i][2]<<setw(16)<<(((temp[i][2]-32)/9)*5)<<setw(10)<<(((temp[i][2]*9)/5)+32)<<'
';
cout << "Day #4:"<<temp[i][3]<<setw(16)<<(((temp[i][3]-32)/9)*5)<<setw(25)<<(((temp[i][3]*9)/5)+32)<<'
';
outfile << "Day #4:"<<temp[i][3]<<setw(16)<<(((temp[i][3]-32)/9)*5)<<setw(10)<<(((temp[i][3]*9)/5)+32)<<'
';
cout << "Day #5:"<<temp[i][4]<<setw(16)<<(((temp[i][4]-32)/9)*5)<<setw(25)<<(((temp[i][4]*9)/5)+32)<<'
';
outfile << "Day #5:"<<temp[i][4]<<setw(16)<<(((temp[i][4]-32)/9)*5)<<setw(10)<<(((temp[i][4]*9)/5)+32)<<'
';
cout << "Day #6:"<<temp[i][5]<<setw(16)<<(((temp[i][5]-32)/9)*5)<<setw(25)<<(((temp[i][5]*9)/5)+32)<<'
';
outfile << "Day #6:"<<temp[i][5]<<setw(16)<<(((temp[i][5]-32)/9)*5)<<setw(10)<<(((temp[i][5]*9)/5)+32)<<'
';
cout << "Day #7:"<<temp[i][6]<<setw(16)<<(((temp[i][6]-32)/9)*5)<<setw(25)<<(((temp[i][6]*9)/5)+32)<<'
';
outfile << "Day #7:"<<temp[i][6]<<setw(16)<<(((temp[i][6]-32)/9)*5)<<setw(10)<<(((temp[i][6]*9)/5)+32)<<'
';
cout << "The average Celsius reading for this 7 day period is: "<<((((temp[i][0]-32)/9)*5)+(((temp[i][1]-32)/9)*5)+(((temp[i][2]-32)/9)*5)+(((temp[i][3]-32)/9)*5)+(((temp[i][4]-32)/9)*5)+(((temp[i][5]-32)/9)*5)+(((temp[i][6]-32)/9)*5))/7<<'
';
cout << "The average Farenheit reading for this 7 day period is: "<<((((temp[i][0]*9)/5)+32)+(((temp[i][1]*9)/5)+32)+(((temp[i][2]*9)/5)+32)+(((temp[i][3]*9)/5)+32)+(((temp[i][4]*9)/5)+32)+(((temp[i][5]*9)/5)+32)+(((temp[i][6]*9)/5)+32))/7<<'
';
outfile << "The average Celsius reading for this 7 day period is: "<<((((temp[i][0]-32)/9)*5)+(((temp[i][1]-32)/9)*5)+(((temp[i][2]-32)/9)*5)+(((temp[i][3]-32)/9)*5)+(((temp[i][4]-32)/9)*5)+(((temp[i][5]-32)/9)*5)+(((temp[i][6]-32)/9)*5))/7<<'
';
outfile << "The average Farenheit reading for this 7 day period is: "<<((((temp[i][0]*9)/5)+32)+(((temp[i][1]*9)/5)+32)+(((temp[i][2]*9)/5)+32)+(((temp[i][3]*9)/5)+32)+(((temp[i][4]*9)/5)+32)+(((temp[i][5]*9)/5)+32)+(((temp[i][6]*9)/5)+32))/7<<'
';
outfile.close();//closes outfile
cout << "
";//newline
do_again();//calls do_again
}//end function--end program
(Edited by supersloth at 3:04 pm on May 14, 2001)
(Edited by supersloth at 3:07 pm on May 14, 2001)

New Topic/Question
Reply




MultiQuote







|