From 61339fbb4f90d3cb2b2d458ec4dc4aa20122b834 Mon Sep 17 00:00:00 2001 From: pleehael47 Date: Wed, 13 Dec 2023 18:44:23 -0500 Subject: [PATCH 1/3] Added extra features of conversion --- project2/Unit_convertor.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/project2/Unit_convertor.c b/project2/Unit_convertor.c index 4caa65f..978a8d8 100644 --- a/project2/Unit_convertor.c +++ b/project2/Unit_convertor.c @@ -19,14 +19,18 @@ int main() { int userinputUSDtoEuro; // User inputted for USD to EURO; int userinputUSDtoJPY; // User inputted for USD to JPY; int userinputUSDtoRMB; // User inputted for USD to RMB; + int userinputUSDtoPESOS; // User inputted for USD to RMB; int userinputOunce; // User inputted for Ounce; int userinputGram; // User inputted for Gram; int fahrenheitToCelcius; // variable that stores the converted F->C; int celciusToFahrenheit; // variable that stores the converted C->F; + int celciusToKelvin; // variable that stores the converted C->F; float USDtoEURO ; // varaible that stores the converted USD->EURO; float USDtoJPY; // stores the converted USD->JPY; float USDtoRMB; // stores the converted USD->RMB; + float USDtoPESOS; // stores the converted USD->RMB; float ounceToPounds; // stores the converted Ounce->Pounds; + float ounceToGram; // stores the converted Ounce->Pounds; float gramsToPounds; // stores the vonerted Grams->Pounds; printf("Welcome to Unit Converter! \n"); @@ -40,6 +44,7 @@ int main() { printf("Here is a list of conversations to choose from: \n"); printf("Enter 1 for Fahrenheit to Celsius. \n"); printf("Enter 2 for Celsius to Fahrenheit. \n"); + printf("Enter 3 for Celsius to Kelvin. \n"); scanf("%d",&tempChoice); if(tempChoice == 1){ printf("Please enter the Fahrenheit degree: \n"); @@ -53,8 +58,16 @@ int main() { celciusToFahrenheit = ((9.0/5.0)*userinputC + 32); printf("Fahrenheit: %d",celciusToFahrenheit); } - else + else if (tempChoice == 3){ + printf("Please enter the Celcius degree: \n"); + scanf("%d",&userinputC); + celciusToKelvin = ((9.0/5.0)*userinputC + 32); + printf("Fahrenheit: %d",celciusToKelvin + 273); + } + else { printf("Please enter the correct choice. \n"); + } + } else if(category == 'C') { @@ -63,6 +76,7 @@ int main() { printf("Enter 1 for USD to Euro. \n"); printf("Enter 2 for USD to JPY. \n"); printf("Enter 3 for USD to RMB. \n"); + printf("Enter 4 for USD to PESOS. \n"); scanf("%d",¤cyChoice); if(currencyChoice == 1){ printf("Please enter the USD amount: \n"); @@ -82,14 +96,22 @@ int main() { USDtoRMB = userinputUSDtoRMB * 6.82; printf("RMB: %.2f",USDtoRMB); } - else + else if(currencyChoice == 4) { + printf("Please enter the USD amount: \n"); + scanf("%d",&userinputUSDtoPESOS); + USDtoPESOS = userinputUSDtoPESOS * 17.26; + printf("RMB: %.2f",USDtoPESOS); + } + else { printf("Please enter correct choice. \n"); + } } else if(category == 'M'){ printf("Welcome to Mass Converter! \n"); printf("Here is a list of conversations to choose from: \n"); printf("Enter 1 for ounces to pounds. \n"); printf("Enter 2 for gram to pounds. \n"); + printf("Enter 2 for ounce to grams. \n"); scanf("%d",&massChoice); if(massChoice == 1){ printf("Please enter the ounce amount: \n"); @@ -103,8 +125,15 @@ int main() { gramsToPounds = userinputGram * 0.00220462; printf("Pounds: %.2f",gramsToPounds); } - else + else if(massChoice == 3) { + printf("Please enter the ounce amount: \n"); + scanf("%d",&userinputOunce); + ounceToGram = userinputOunce * 0.00220462; + printf("Pounds: %.2f", ounceToGram); + } + else { printf("Please enter the correct choice. \n"); + } } return 0; } \ No newline at end of file From f02c1e279832f7a992e2f46b531ec1e6dfa27a6c Mon Sep 17 00:00:00 2001 From: pleehael47 Date: Wed, 13 Dec 2023 18:45:47 -0500 Subject: [PATCH 2/3] Added comments --- project2/Unit_convertor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project2/Unit_convertor.c b/project2/Unit_convertor.c index 978a8d8..3822a42 100644 --- a/project2/Unit_convertor.c +++ b/project2/Unit_convertor.c @@ -58,7 +58,7 @@ int main() { celciusToFahrenheit = ((9.0/5.0)*userinputC + 32); printf("Fahrenheit: %d",celciusToFahrenheit); } - else if (tempChoice == 3){ + else if (tempChoice == 3){ //added a celsius to kelvin feature printf("Please enter the Celcius degree: \n"); scanf("%d",&userinputC); celciusToKelvin = ((9.0/5.0)*userinputC + 32); @@ -96,7 +96,7 @@ int main() { USDtoRMB = userinputUSDtoRMB * 6.82; printf("RMB: %.2f",USDtoRMB); } - else if(currencyChoice == 4) { + else if(currencyChoice == 4) { //added a usd to pesos feature printf("Please enter the USD amount: \n"); scanf("%d",&userinputUSDtoPESOS); USDtoPESOS = userinputUSDtoPESOS * 17.26; @@ -125,7 +125,7 @@ int main() { gramsToPounds = userinputGram * 0.00220462; printf("Pounds: %.2f",gramsToPounds); } - else if(massChoice == 3) { + else if(massChoice == 3) { //added a ounce to grams feature printf("Please enter the ounce amount: \n"); scanf("%d",&userinputOunce); ounceToGram = userinputOunce * 0.00220462; From 90c0106c36d9113aa3440efb9b75a7a22e25fac4 Mon Sep 17 00:00:00 2001 From: pleehael47 Date: Wed, 13 Dec 2023 21:24:32 -0500 Subject: [PATCH 3/3] Fixed errors I made --- project2/Unit_convertor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/project2/Unit_convertor.c b/project2/Unit_convertor.c index 3822a42..9caebb3 100644 --- a/project2/Unit_convertor.c +++ b/project2/Unit_convertor.c @@ -19,18 +19,18 @@ int main() { int userinputUSDtoEuro; // User inputted for USD to EURO; int userinputUSDtoJPY; // User inputted for USD to JPY; int userinputUSDtoRMB; // User inputted for USD to RMB; - int userinputUSDtoPESOS; // User inputted for USD to RMB; + int userinputUSDtoPESOS; // User inputted for USD to PESOS; int userinputOunce; // User inputted for Ounce; int userinputGram; // User inputted for Gram; int fahrenheitToCelcius; // variable that stores the converted F->C; int celciusToFahrenheit; // variable that stores the converted C->F; - int celciusToKelvin; // variable that stores the converted C->F; + int celciusToKelvin; // variable that stores the converted C->K; float USDtoEURO ; // varaible that stores the converted USD->EURO; float USDtoJPY; // stores the converted USD->JPY; float USDtoRMB; // stores the converted USD->RMB; float USDtoPESOS; // stores the converted USD->RMB; float ounceToPounds; // stores the converted Ounce->Pounds; - float ounceToGram; // stores the converted Ounce->Pounds; + float ounceToGram; // stores the converted Ounce->Gram; float gramsToPounds; // stores the vonerted Grams->Pounds; printf("Welcome to Unit Converter! \n"); @@ -128,7 +128,7 @@ int main() { else if(massChoice == 3) { //added a ounce to grams feature printf("Please enter the ounce amount: \n"); scanf("%d",&userinputOunce); - ounceToGram = userinputOunce * 0.00220462; + ounceToGram = userinputOunce * 28.34; printf("Pounds: %.2f", ounceToGram); } else {