Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int mainmenu(int y)
- {
- int c;
- char username1[50], password1[50];
- FILE*database;
- struct user
- {
- char student_ID[50], course[50], email[50], sem[50],name[50];
- int age;
- };
- struct user s;
- if(y==1)
- {
- database=fopen("database.dat","a");
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\t\tPlease complete the registration form neatly. Thanks!\n");
- printf("\n\n\tUsername: ");
- gets(username1);
- fgets(username1,50,stdin);
- fprintf(database,"\nUsername:\t%s", username1);
- printf("\n\tPassword: ");
- fgets(password1,50,stdin);
- fprintf(database,"Password:\t%s", password1);
- printf("\n\tName: ");
- fgets(s.name,50,stdin);
- fprintf(database,"Name:\t%s", s.name);
- printf("\n\tAge: ");
- scanf("%d", &s.age);
- fprintf(database,"Age:\t%d", s.age);
- gets(s.student_ID);
- printf("\n\tStudent ID: ");
- fgets(s.student_ID,50,stdin);
- fprintf(database,"Studen ID:\t%s", s.student_ID);
- printf("\n\tCourse: ");
- fgets(s.course,50,stdin);
- fprintf(database,"Course:\t%s", s.course);
- printf("\n\tSemester: ");
- fgets(s.sem,50,stdin);
- fprintf(database,"Semester:\t%s", s.sem);
- printf("\n\tE-Mail: ");
- fgets(s.email,50,stdin);
- fprintf(database,"E-Mail:\t%s", s.email);
- fclose(database);
- printf("\n\n\tYou have succesfully register.");
- printf("\n\n\tPress any key to continue login...");
- getch();
- goto login;
- }
- else if(y==2)
- {
- char username[50], password[50],attempt, attempt1;
- login:
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\t\t\tEnter your username and password:\n");
- printf("\n\t\t\tUsername:\t");
- scanf("%s", &username);
- printf("\n\t\t\tPassword:\t");
- scanf("%s", &password);
- attempt=strcmp(password,password1);
- attempt1=strcmp(username,username1);
- if(attempt==0&&attempt1==0)
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tLogin Successfully!\n");
- printf("\t\t\t\tPress enter to continue...");
- getch();
- homepage();
- }
- else
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\tEither your name or your login id is wrong.\n\n\tIf you did not register yet please do it so at the main menu.");
- printf("\n\n\tPress 1 to try again and 2 to go back to the main menu.");
- printf("\n\n\tElse to exit.");
- scanf("%d", &c);
- if(c==1)
- {
- system("cls");
- goto login;
- }
- if(c==2)
- {
- system("cls");
- main();
- }
- else
- {
- return 0;
- }
- }
- }
- else if(y==3)
- {
- exit:
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\a\n\t\t\tThanks for using this programme.\n\n\n\n\n\n\n\n");
- return 0;
- }
- else if(y==4)
- {
- homepage(); }
- else
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\t\t\t\tInvalid input.");
- printf("\n\n\t\tPress 1 to go back and others key to close: ");
- scanf("%d", &y);
- if(y==1)
- {
- main();
- }
- else
- {
- goto exit;
- }
- return 0;
- }
- return 0;
- }
- int homepage()
- {
- FILE*registration;
- char ch,opt3;
- int i,opt=0;
- int option, options,x,z;
- float HE, R, HP, CHE, CR, CHP, work, Qin, Qout, Thigh, Tlow;
- homepage:
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n\n\n");
- printf("\t_____________________________________________________\n");
- printf("\n\tA. Second Law of Thermodynamics\t\tE. My Profile \n");
- printf("\n\tB. General Energy Analysisis\t\tF. Log Out\n");
- printf("\n\tC. Properties of Pure Substance\t\tG. About Us\n");
- printf("\n\tD. Energy Analysis of Control Volume\tH. Exit\n");
- printf("\n\tEnter Your Selection: ");
- fflush(stdin);
- scanf("%c", &opt3);
- switch(opt3)
- {
- aiman:
- case 'a':case 'A':
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\t--------Welcome to The Second Law of Thermodynamics--------\n\n");
- printf("\tPlease choose the following options below\n");
- printf("\t1. Heat Engine\n");
- printf("\t2. Refrigerators\n");
- printf("\t3. Heat Pumps\n");
- printf("\t4. Carnot Heat Engine\n");
- printf("\t5. Carnot Refrigerators\n");
- printf("\t6. Carnot Heat Pump\n");
- printf("\t7. Main Menu.\n\n");
- printf("\tEnter Selection : ");
- scanf("%d", &option);
- if(option == 1)
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\tThis program will calculate the thermal efficiency of Heat Engine\n");
- printf("\n\tPlease choose which formula you will use:\n\n");
- printf("1. First Formula(use when value of Work and Heat Enter are given in system)\n");
- printf("2. Second Formula(use when value of Heat Enter and Heat Out are given in\n system)\n");
- printf("\n\tSelection: ");
- scanf("%d", &options);
- if(options == 1)
- {
- printf("\n\tPlease enter the value of Work : ");
- scanf("%f", &work);
- printf("\n\tPlease enter the value of Heat Enter : ");
- scanf("%f", &Qin);
- HE = work/Qin;
- printf("\n\tThe value of your Thermal Efficiency is %.4f\n", HE);
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- else if(options == 2)
- {
- printf("\n\tPlease enter the value of Heat Enter :");
- scanf("%f", &Qin);
- printf("\n\tPlease enter the value of Heat Out :");
- scanf("%f", &Qout);
- HE = 1 - (Qout/Qin);
- printf("\n\tThe value of Thermal Efficiency is %.4f\n", HE);
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- else
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- }
- else if(option == 2)
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\t This program will calculate the Coefficient of Perfomance\n\t\t\t\tof Refrigerators\n");
- printf("\n\tPlease choose which formula you will use\n\n");
- printf("1. First Formula(use when value of Work and Heat Out are given in system)\n");
- printf("2. Second Formula(use when value of Heat Enter and Heat Out are given in\n system)\n");
- printf("\n\tSelection: ");
- scanf("%d", &options);
- if(options == 1)
- {
- printf("\n\n\tPlease enter the value of Work : ");
- scanf("%f", &work);
- printf("\n\tPlease enter the value of Heat Enter : ");
- scanf("%f", &Qout);
- R = Qout/work;
- printf("\n\tThe value of the Coefficient of Perfomance is %.4f\n", R);
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- else if(options == 2)
- {
- printf("\n\n\tPlease enter the value of Heat Enter : ");
- scanf("%f", &Qin);
- printf("\n\tPlease enter the value of Heat Out : ");
- scanf("%f", &Qout);
- R = Qout/( Qin - Qout);
- printf("\n\tThe value of the Coefficient of Perfomance is %.4f\n", R);
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- else
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- }
- else if(option == 3)
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\t\tThis program will calculate the Coefficient\n\t\t\tof Perfomance of Heat Pumps\n");
- printf("\n\tPlease choose which formula you will use\n");
- printf("\n1. First Formula(use when value of Work and Heat Enter are given in system)\n");
- printf("2. Second Formula(use when value of Heat Enter and Heat Out are given in\n system)\n");
- printf("\n\n\tSelection: ");
- scanf("%d", &options);
- if(options == 1)
- {
- printf("\n\tPlease enter the value of Work :");
- scanf("%f", &work);
- printf("\n\tPlease enter the value of Heat Enter :");
- scanf("%f", &Qin);
- HP = Qin/work;
- printf("\n\tThe value of the Coefficient of Perfomance is %.4f\n", HP);
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- else if(options == 2)
- {
- printf("\n\tPlease enter the value of Heat Enter :");
- scanf("%f", &Qin);
- printf("\n\tPlease enter the value of Heat Out :");
- scanf("%f", &Qout);
- HP = Qin/( Qin - Qout);
- printf("\n\tThe value of the Coefficient of Perfomance is %.4f\n", HP);
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- else
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- }
- else if(option == 4)
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\t\tThis program will calculate the Thermal Efficiency\n\t\t\t of Carnot Heat Engine\n");
- printf("\n\tPlease enter the value of High Temperature :");
- scanf("%f", &Thigh);
- printf("\n\tPlease enter the value of Low Temperature :");
- scanf("%f", &Tlow);
- CHE = 1 - ( Tlow / Thigh);
- printf("\n\n\tThe value of Thermal Efficiency is %.4f\n", CHE);
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- else if(option == 5)
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\t\tThis program will calculate the Coefficient\n\t\t of Perfomance of Carnot Refrigerators\n");
- printf("\n\tPlease enter the value of High Temperature : ");
- scanf("%f", &Thigh);
- printf("\n\tPlease enter the value of Low Temperature : ");
- scanf("%f", &Tlow);
- CR = Tlow / (Thigh - Tlow);
- printf("\n\n\tThe value of Coefficient of Perfomance is %.4f\n", CR);
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- else if(option == 6)
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\tThis program will calculate the Coefficient of Perfomance of Heat Pumps\n");
- printf("\nPlease enter the value of High Temperature :\n");
- scanf("%f", &Thigh);
- printf("\nPlease enter the value of Low Temperature :\n");
- scanf("%f", &Tlow);
- CHP = Thigh / (Thigh - Tlow);
- printf("The value of Thermal Efficiency is %.4f\n", CHP);
- getch();
- goto aiman;
- }
- if(option==7)
- {
- goto homepage;
- }
- else
- {
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\tInvalid input...");
- printf("\n\n\tPress Enter to continue...");
- getch();
- goto aiman;
- }
- break;
- case 'b':case 'B':
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\t\t\tENERGY TRANSFER OF CLOSED SYSTEM");
- printf("\n\t\t\t________________________________");
- while(opt!=4)
- {
- printf("\n\n\tPlease select:\n");
- printf("\n\t1. Potential Energy");
- printf("\n\t2. Kinetic Energy");
- printf("\n\t3. Energy Trasfer");
- printf("\n\t4. Quit\n\t:");
- scanf("%d", &opt);
- if(opt==1)
- {
- potential_energy();
- }
- else if(opt==2)
- {
- kinetic_energy();
- }
- else if(opt==3)
- {
- energy_transfer();
- }
- else{goto homepage;}
- }
- return 0;
- break;
- case 'c': case 'C':
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\t\t\tENERGY ANALYSIS OF CONTROL VOLUME");
- printf("\n\t\t\t________________________________");
- while(opt!=3)
- {
- printf("\n\n\tPlease select:\n");
- printf("\n\t1. Quality");
- printf("\n\t2. Ideal Gas EoS");
- printf("\n\t3. Quit\n\t:");
- scanf("%d", &opt);
- if(opt==1)
- {
- quality();
- }
- else if(opt==2)
- {
- ideal_gas();
- }
- else
- {goto homepage;}
- }
- return 0;
- break;
- case 'd': case 'D':
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\t\t\t\t ENTROPY");
- printf("\n\t\t\t\t _______");
- break;
- case 'e': case 'E':
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- registration=fopen( "database.dat","r");
- if(registration==NULL)
- {
- puts("\n\n\t\t The database cannot read your profile.\n\t\tEither it is corrupted or you are not registered.");
- puts("\n\n\t\tThe system will now close for safety measurements.");
- break;
- }
- else
- {
- while (1)
- {
- ch=fgetc(registration);
- if(ch==EOF)
- break ;
- printf ( "%c", ch);
- }
- fclose(registration);
- }
- printf("\n\nPress Enter to continue...");
- getch();
- goto homepage;
- break;
- case 'f': case 'F':
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\n\t\t\t\t>>>>Logout<<<<");
- getch();
- main();
- break;
- case 'g': case 'G':
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n\n\n");
- printf("\n\n\tThe mission of Thermo Company is to develop and supply");
- printf("\n\tsuperior software, databases and services for technical ");
- printf("\n\tcalculations involving thermodynamics or thermal calculations.\n");
- printf("\n\tThermo Company continuously develops our software and");
- printf("\n\tdatabases in order to create new and better tools for\n\tsuch calculations.");
- printf("\n\n\tPress 1 to exit, else to go back: ");
- scanf("%d", &z);
- switch(z)
- {
- case 1: goto exit;
- break;
- default:
- goto homepage;
- break;
- }
- break;
- case 'h': case 'H':
- system("cls");
- exit:
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\a\n\t\t\tThanks for using this programme.\n\n\n\n\n\n\n\n");
- break;
- default:
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\t\t\t\tInvalid input.");
- printf("\n\n\t\tPress 1 to go back and others key to close: ");
- scanf("%d", &x);
- if(x==1)
- {
- goto homepage;
- }
- else
- {
- goto exit;
- }
- break;
- }
- }
- energy_transfer()
- {
- float energy_transfer,heat_transfer, work_transfer, mass_flow;
- printf("\nEnter heat transfer :");
- scanf("%f", &heat_transfer);
- printf("\nEnter work transfer :");
- scanf("%f", &work_transfer);
- printf("\nEnter mass flow :");
- scanf("%f", &mass_flow);
- energy_transfer = heat_transfer + work_transfer + mass_flow;
- printf("\nEnergy transfer : %.2f", energy_transfer);
- }
- kinetic_energy()
- {
- float kinetic_energy,mass,gravity,height;
- printf("\nEnter mass (kg):");
- scanf("%f", &mass);
- printf("\nEnter Gravity ");
- scanf("%f", &gravity);
- printf("\nEnter height (m)");
- scanf("%f", &height);
- kinetic_energy = mass*gravity*height;
- printf("\nKinetic Energy : %.2f", kinetic_energy);
- }
- potential_energy()
- {
- float potential_energy,mass,velocity;
- printf("\nEnter mass (kg):");
- scanf("%f", &mass);
- printf("\nEnter velocity (m\s) :");
- scanf("%f", &velocity);
- potential_energy = (mass*velocity*velocity)/2;
- printf("\nPotential Energy : %.2f", potential_energy);
- }
- ideal_gas ()
- {
- float ideal_gas, pressure, volume, mass, gas_constant,temperature;
- printf("Enter pressure :");
- scanf("%f", &pressure);
- printf("Enter volume :");
- scanf("%f", &volume);
- printf("Enter mass :");
- scanf("%f", &mass);
- printf("Enter gas constant :");
- scanf("%f", &gas_constant);
- printf("Enter temperature :");
- scanf("%f", &temperature);
- ideal_gas = (gas_constant*mass*temperature)/(pressure*volume);
- printf("Ideal gas EoS : %.2f", ideal_gas);
- }
- quality ()
- {
- float quality,v_f, v_average, v_fg;
- printf("Enter v or v average :\n");
- scanf("%f", &v_average);
- printf("Enter vf :\n");
- scanf("%f", &v_f);
- printf("Enter vfg :");
- scanf("%f", &v_fg);
- quality = (v_f*v_average)/v_fg;
- printf("Quality : %.2f", quality);
- }
- int main()
- {
- int opt1,y;
- main:
- system("cls");
- printf("\t\t\t\t==============\n");
- printf("\t\t\t\tTHERMO COMPANY\n");
- printf("\t\t\t\t==============\n");
- printf("\n\t\t\t\tWelcome Guest!\n");
- printf("\n\t\t\t\t______________\n");
- printf("\n\t\t\t\t1. REGISTER");
- printf("\n\t\t\t\t2. LOGIN\n");
- printf("\t\t\t\t3. EXIT\n");
- printf("\t\t\t\t______________\n");
- printf("\n\n\t\t\t\tEnter: ");
- scanf("%d", &opt1);
- mainmenu(opt1);
- }
Add Comment
Please, Sign In to add comment