I am suppose to write a program that presents a main menu to a user. The main menu should present the user with two option. 1) convert a temperature or 2) quit the program. If the user selects the first option, she should be prompted to enter her name, after which the screen should clear, followed by a presentation of a conversion menu the conversion menu must provide six temperature conversions 1) Fahrenheit to celsius 2)celsius to fahrenheit 3) fahrenheit to kelvin 4) celsius to kelvin 5) kelvin to fahrenheit 6) kelvin to celsius as well as a seventh option to return to the main menu.

the output should display the original input temp and the converted temperature plus the user name.

ex:
Alice conversions:
99.9 degrees fahrenheit = 88.8 kelvins

we also have to clear displays between users that is when the is user returns to the main menu but does not quit the program clear the screen for the next user.

in addition to diplaying the conversions to the screen it must collect the following data written to a file tmpstat.txt
total conversions by type for each user
total conversion for each user
total conversion by type for all users
total conversion for all user.

you must use functions and no passing by value.

Here is my source code i wrote up i need help in it because i'm new to c programming and i have no clue as to how to collect the dat to write to the file? I also need help cleaning up my program.

program:
Code:
/* Program name: project5.c
 * Author: William Woo
 * CS 223: Section 03
 * Date written: 12/25/2002
 * Description: This program uses menus to provide temperature conversions.
 */

#include <stdio.h>
#include <string.h>
#define MAX 20

void Greetings(void);
void getchoice(void);
void cmenu(void);
void ftoc(double temp, char name);
void ctof(double temp, char name);
void ftoK(double temp, char name);
void ctoK(double temp, char name);
void Ktof(double temp, char name);
void Ktoc(double temp, char name);
void displayresult(double Ctemp, double temp, char name);

int main(void)
{
	Greetings();
    getchoice();
    
	return (0);
}

void Greetings(void)
{   
   printf("Hello, this program displays menu options for temperature conversions\n");
   printf("of Fahrenheit, Celsius, and Kelvin.\n\n\n");
}

void getchoice(void)
{
   char ch;
   char *name[MAX];
   
   printf("          Main Menu           \n");
   printf("------------------------------\n");
   printf("a. Temperature Conversion\n");
   printf("q. Quit the program\n");
   printf("Enter the letter of your choice:\n");
   scanf("%c", &ch);
   
   if (ch == 'a') 
   {
	   printf("Hi, please enter your first name.\n");
       scanf("%s", &name);
	   printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
	   cmenu();
   }
   else (ch == 'q');
	   printf("Goodbye!\n");
   
}

void cmenu(void)
{
   int choice;
   double temp;
   char name;
   
       while (choice != 7)
	   {
       printf("       Conversion Menu        \n");
       printf("------------------------------\n");
       printf("1. Fahrenheit to Celsius\n");
       printf("2. Celsius to Fahrenheit\n");
       printf("3. Fahrenheit to Kelvin\n");
       printf("4. Celsius to Kelvin\n");
       printf("5. Kelvin to Fahrenheit\n");
       printf("6. Kelvin to Celsius\n");
       printf("7. Main Menu\n");
	   printf("Enter the number of your choice:");
	   scanf("%d", &choice);
	   
   
	   
	   switch (choice)
	   {
           case 1 : ftoc(temp, name);
			        break;

           case 2 : ctof(temp, name);
			        break;
	
	       case 3 : ftoK(temp, name);
			        break;

	       case 4 : ctoK(temp, name);
			        break;

	       case 5 : Ktof(temp, name);
			        break;

	       case 6 : Ktoc(temp, name);
			        break;

	       case 7 : getchoice();
			        break;
			        
	   }  
   }

}

void getdata(double *temp)
{
	printf("Please enter your temperature to be converted:\n");
	scanf("%lf", temp);
}

void ftoc(double temp, char name)
{
     
	double Ctemp;
	getdata(&temp);
	Ctemp = (temp * 1.8) + 32;
	displayresult(Ctemp, temp, &name);
}
    
void ctof(double temp, char name)
{
	double Ctemp;
	getdata(&temp);
	Ctemp = (temp - 32) / 1.8;
	displayresult(Ctemp, temp, &name);
}

void ftoK(double temp, char name)
{
    double Ctemp;
	getdata(&temp);
	Ctemp = ((temp * 1.8) + 32) +273.15;
    displayresult(Ctemp, temp, &name);
}
void ctoK(double temp, char name)
{
	double Ctemp;
	getdata(&temp);
	Ctemp = temp + 273.15;
    displayresult(Ctemp, temp, &name);
}

void Ktof(double temp, char name)
{
	double Ctemp;
	getdata(&temp);
	Ctemp = ((temp - 273.15) * 1.8) + 32;
    displayresult(Ctemp, temp, &name);
}

void Ktoc(double temp, char name)
{
	double Ctemp;
	getdata(&temp);
	Ctemp = temp - 273.15;
    displayresult(Ctemp, temp, &name);
}

void displayresult(double Ctemp, double temp, char name)
{
	printf("%s's Conversions:\n\n", &name);
    printf("Original temperature was %.1lf and converted temperature is %.1lf.\n\n", temp, Ctemp);
}




&#91;code]&#91;/code]tagged by Salem