Need help solving  [Display] Answer: (num) Ounces is (num) grams Choice #5 should end right after choosing the "5. Exit - Do nothing (default) and not ask for "Please enter the value to be converted:" Here is my Code, Please follow and add what is needed to  It does not give the ending value answers of 1-4

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need help solving 
[Display] Answer: (num) Ounces is (num) grams

Choice #5 should end right after choosing the "5. Exit - Do nothing (default)
and not ask for "Please enter the value to be converted:"

Here is my Code, Please follow and add what is needed to 

It does not give the ending value answers of 1-4

char choice;
float value, result, converted;
/* Welcome the user*/
printf("Welcome to weightem!");
/* Display a message on what the program will do*/
printf(" This program will convert weights from English to Metric or Metric to English. Indicate
lection below. \n");
/* Display in numerical numbers, pounds to kilos, kilos to pounds, ounces to grams, grams to ounces*/
printf("1. Pounds to Kilos\n");
printf("2. Kilos to Pounds\n");
III
printf("3. Ounces to Grams\n");
printf("4. Grams to Ounces\n");
printf("5. Exit - Do nothing (default) ");
// User enters their choice of value
printf("\nyour choice: ");
scanf("%c", schoice);
// float values
■
printf("Please enter the value to be converted: ");
scanf("%f", &value);
// Chars
char* from_unit;
char* to unit;
switch (choice) (
case '1':
case 'p':
case 'p':
printf("please enter value in pounds: ");
scanf("%f", &value);
converted
value
0.4536;
from_unit = "pounds";
break;
You
break;
||||
break;
break;
from_unit = "kilograms";
to unit "pounds";
J
case '3':
case 'o':
case '0':
printf("Please enter value in ounces: ");
scanf("%f", &value);
converted = value * 28.35;
from_unit = "ounces";
to_unit "grams";
case '4':
case 'g':
case 'G':
printf("Please enter value in grams: ");
scanf("%f", &value);
converted = value / 28.35;
from_unit = "grams";
to_unit = "ounces";
case '5':
case 'e':
case 'E':
// Give the answer to the User
1/
printf("%f, %s is %f %s\n, value, from_unit, converted, to_unit);
// Thank user for using weightem and goodbye
ala
printf("Thank you for using weightem! \n");
return 0;
printf("Invalid choice Thank you for using the program. \n");
return 1;
Transcribed Image Text:char choice; float value, result, converted; /* Welcome the user*/ printf("Welcome to weightem!"); /* Display a message on what the program will do*/ printf(" This program will convert weights from English to Metric or Metric to English. Indicate lection below. \n"); /* Display in numerical numbers, pounds to kilos, kilos to pounds, ounces to grams, grams to ounces*/ printf("1. Pounds to Kilos\n"); printf("2. Kilos to Pounds\n"); III printf("3. Ounces to Grams\n"); printf("4. Grams to Ounces\n"); printf("5. Exit - Do nothing (default) "); // User enters their choice of value printf("\nyour choice: "); scanf("%c", schoice); // float values ■ printf("Please enter the value to be converted: "); scanf("%f", &value); // Chars char* from_unit; char* to unit; switch (choice) ( case '1': case 'p': case 'p': printf("please enter value in pounds: "); scanf("%f", &value); converted value 0.4536; from_unit = "pounds"; break; You break; |||| break; break; from_unit = "kilograms"; to unit "pounds"; J case '3': case 'o': case '0': printf("Please enter value in ounces: "); scanf("%f", &value); converted = value * 28.35; from_unit = "ounces"; to_unit "grams"; case '4': case 'g': case 'G': printf("Please enter value in grams: "); scanf("%f", &value); converted = value / 28.35; from_unit = "grams"; to_unit = "ounces"; case '5': case 'e': case 'E': // Give the answer to the User 1/ printf("%f, %s is %f %s\n, value, from_unit, converted, to_unit); // Thank user for using weightem and goodbye ala printf("Thank you for using weightem! \n"); return 0; printf("Invalid choice Thank you for using the program. \n"); return 1;
s158a12@cisweb:~/p02/ex1
3. Ounces to Grams
4. Grams to Ounces
5. Exit
Do nothing (default)
your choice: 5
Please enter the value to be converted: 4
Thank you for using weightem!
[s158a12@cisweb ex1]$ gcc weightem.c
[s158a12@cisweb ex1]$ a.out weightem.c
0
Welcome to weightem! This program will convert weights from Engli
to Metric or Metric to English. Indicate which conversaion from
e selection below.
1. Pounds to Kilos
2. Kilos to Pounds
3. Ounces to Grams
4. Grams to Ounces
5. Exit
your choice: 3
Do nothing (default)
Please enter the value to be converted: 5.25
Please enter value in ounces: Should display "Answer 5.25 ounces
148.83 grams"
PRO MANAGE
Bhaiy
Welcome to weightem! This program will convert weights from Eng
e selection below.
1. Pounds to Kilos
2. Kilos to Pounds
3. Ounces to Grams
4. Grams to Ounces
5. Exit - Do nothing (default)
your choice: 5
Please enter the value to be converted:4
Thank you for using weightem!
Welcome to weightem. The program will convert weights from English to Metric or Metric to
English. Indicate which conversion from the selection below.
1. Pounds to Kilos
2. Kilos to Pounds
Ounces to Grams.
3.
4. Grams to Ounces
5. Exit - Do nothing (default)
Your choice: 3 User entered value is 3
Enter the number of ounces to convert: 5.25 User entered value is 5.25
Answer: 5.25 ounces is 148.83 grams
Thank you for using weightem. Bye!
← Make sure to use the correct conversion and labels
Transcribed Image Text:s158a12@cisweb:~/p02/ex1 3. Ounces to Grams 4. Grams to Ounces 5. Exit Do nothing (default) your choice: 5 Please enter the value to be converted: 4 Thank you for using weightem! [s158a12@cisweb ex1]$ gcc weightem.c [s158a12@cisweb ex1]$ a.out weightem.c 0 Welcome to weightem! This program will convert weights from Engli to Metric or Metric to English. Indicate which conversaion from e selection below. 1. Pounds to Kilos 2. Kilos to Pounds 3. Ounces to Grams 4. Grams to Ounces 5. Exit your choice: 3 Do nothing (default) Please enter the value to be converted: 5.25 Please enter value in ounces: Should display "Answer 5.25 ounces 148.83 grams" PRO MANAGE Bhaiy Welcome to weightem! This program will convert weights from Eng e selection below. 1. Pounds to Kilos 2. Kilos to Pounds 3. Ounces to Grams 4. Grams to Ounces 5. Exit - Do nothing (default) your choice: 5 Please enter the value to be converted:4 Thank you for using weightem! Welcome to weightem. The program will convert weights from English to Metric or Metric to English. Indicate which conversion from the selection below. 1. Pounds to Kilos 2. Kilos to Pounds Ounces to Grams. 3. 4. Grams to Ounces 5. Exit - Do nothing (default) Your choice: 3 User entered value is 3 Enter the number of ounces to convert: 5.25 User entered value is 5.25 Answer: 5.25 ounces is 148.83 grams Thank you for using weightem. Bye! ← Make sure to use the correct conversion and labels
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Graphical User Interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education