Question

In: Computer Science

Write an algorithm to describe how to convert a user input from ounces to grams, drams...

Write an algorithm to describe how to convert a user input from ounces to grams, drams and pounds. Use enough detail that you have between five and ten steps. List any assumptions.

         a) Assumptions

         b) Steps

Solutions

Expert Solution


Algorithm for converting ounces to grams and pounds:

Start
  
   num ounces
   num grams
   num pounds

   Set grams=0
   Set pounds=0

   Set OUNCES_TO_GRAMS=28.3495
   Set OUNCES_TO_POUNDS=0.0625

   Print "Enter number of ounces"
   Read ounces

   Calculate grams=ounces*OUNCES_TO_GRAMS
   Calculate pounds=ounces*OUNCES_TO_POUNDS

   Print ounces , " ounces = ", grams, "grams"
   Prnt ounces , " ounces = ", pounds , " pounds"

Stop
  

----------------------------------------------------------------------------------------------------------------

Flow-chart :


Related Solutions

Write a program that read the input from user and convert it to binary and hex...
Write a program that read the input from user and convert it to binary and hex in C language.
Write an algorithm (flowchart OR Pseudocode) for the following problem Take input character from the user...
Write an algorithm (flowchart OR Pseudocode) for the following problem Take input character from the user unless he enters '$'. Thereafter display how may vowels were entered by the user. Also display the number of each vowel ('a', 'e', 'i', 'o' and 'u') separately. For example if the user enters B a b e c o o d i u g o a l $ Then we have the output below: #A=2 #E=1 #I=1 #O=3 #U=2
Write a program in javascript to encrypt and decrypt the user input using the caesar algorithm...
Write a program in javascript to encrypt and decrypt the user input using the caesar algorithm with the substitution algorithm. Specify the min and max of the message user can enter to encrypt. Specify the length of the key user can enter to encrypt and decrypt the message. document your design by words or diagrams.
In Java, how can I convert a string user input for example a student starts a...
In Java, how can I convert a string user input for example a student starts a uni degree in "Winter/2022", to a date type, and then once I have done that, add 3 years to that value, and changing the season, so for example Student Started: Winter/2022 and Student Finished: Summer/2025. Is there any possible way to do this? Thank you.
Convert this strategy into an algorithm and write it below. remember to provide an algorithm header,...
Convert this strategy into an algorithm and write it below. remember to provide an algorithm header, number the algorithm steps and to use pseudocode conventions.          Scan the input array A, counting the number of negative, zero and positive numbers. Let these counts be x, y and z respectively.          Create a new array B of the same size and set a local variable neg to 1, zero to x+1, and pos to x+y+1.          Scan the input array from...
A simple way to write the code to convert millileters to ounces in java
A simple way to write the code to convert millileters to ounces in java
Write Java program that asks a user to input a letter, converts the user input to...
Write Java program that asks a user to input a letter, converts the user input to uppercase if the user types the letter in lowercase, and based on the letter the user the user enters, display a message showing the number that matches the letter entered. For letters A or B or C display 2 For letter D or E or F display 3 For letter G or H or I display 4 For letter J or K or L...
write a program that takes the input value from the user and calculate the sum from...
write a program that takes the input value from the user and calculate the sum from that number to zero in MIPS
Given the variable as coefficient, exponent and input. Write methods that will convert the input into...
Given the variable as coefficient, exponent and input. Write methods that will convert the input into String in the following format: coefficient = 1, exponent=1 input=-3 Method 1 does not take any input, (just coefficient and exponent only) so it should return output as: "1.0 * x^1" (with inverted comma) Method 2 takes given input, so it should return output as: "1.0 * -3.0^1" (with inverted comma) ( Note coefficient 1 and exponent 3 are now 1.0 and 3.0 in...
Write a program that accepts as input the mass, in grams, and density, in grams per...
Write a program that accepts as input the mass, in grams, and density, in grams per cubic centimeters, and outputs the volume of the object using the formula: volume = mass / density. Format your output to two decimal places. ** Add Comments
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT