Assignment overview We would like students to experience command line input with C types of character,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Assignment overview We would like students to experience command line input with C types of character, int, float, and long, to understand and use C types such as char, int, float, and long, as well as the flow control structures studied in class, and to use functions and recursive functions. This assignment consists of two parts. In part one, you are required to write a C program to perform some simple conversions. In part two, you are to write a C program to calculate value of exponential numbers. Part one: 70% The goal of the exercise is to implement a simple converter, called "converter.c", which works as follows. (1) First, program will prompt users with the following five options and the user is asked what she/he wants to do. A single integer can be read with the following six actions associated with different values of the character. You can assume that the user will always enter a single integer. 1 for conversion between Celsius and Fahrenheit 2 for conversion between Centimetre and Inch 3 for conversion between Kilometer and Mile 4 for conversion between Gallon and Liter 0 for quit For any other integer, repeat step (1) (2) In case of 1, 2, 3, and 4, each action should be implemented as a function. In case of 0, the program will terminate. For all the other values, repeat step (1). (3) In case of 1 to 4, the program will ask the direction of the conversion. In each case, a single character can be entered whose value corresponding to each conversion direc- tion. In case of 1, the program will prompt the user for two choices and wait for a character input 1 . C for conversion from Celsius to Fahrenheit . F for conversion from Fahrenheit to Celsius . For any other character, repeat this case In case of 2, the program will prompt the user for two choices and wait for a character input . C for conversion from Centimetre to Inch . I for conversion from Inch to Centimetre For any other character, repeat this case In case of 3, the program will prompt the user for two choices and wait for a character input . K for conversion from Kilometer to Mile . M for conversion from Mile to Kilometer . For any other character, repeat this case In case of 4, the program will prompt the user for two choices and wait for a character input G for conversion from Gallon to Liter . L for conversion from Liter to gallon For any other character, repeat this case HINT: to read a character properly, your program should handle the leading white- space character, space character, tab character, and end of line, or new line, character, if any. Instead of scanf("%c", &ch);, you may consider scanf(" %c", &ch);. (4) Then the program asks for the input value, properly displays the result and returns to Step (1). The input value should be a float number and we assume the user will always enter valid numbers. Your program should prompt user and display the result to user in a descriptive manner. (5) Your program should follow good programming styles, i.e. write clear code, choose good variable names, use appropriate functions, make proper comments, and etc. 2 Part two: 30% The goal of this exercise is to implement a power of two calculator, called "power2_calculator.c" with recursive function. (1) First, the user is asked for the exponent and we assume that exponent is a non-negative integer number. If the exponent entered is 0, display the result and then terminate the program. (2) Then the power of two function is calculated using a recursive function in logarithmic time in terms of the value of the exponent inputted. The result is then displayed. Hint: for n = 0 for n > 0 2n = 2 = 1 (2/2)2 if n is even { (2(n-1)/2)2 * 2 if n is odd (3) You can assume that the user always enter an integer number for the exponent. After each calculation, go to (1). (4) You should use the unsigned long for the calculation and print of power of two num- bers. (5) Your program should follow good programming styles, i.e. write clear code, choose good variable names, use appropriate functions, make proper comments, and etc. Testing your program You should test your program by running it on Gaul. For part one, each case should be tested at least once. For part two, different exponents should be tested and you should show one exponent value, e.g. smallest, that will make the program result unreliable. Capture the screen of your testing by using script command. There should be two resulting script files, converter.script and power2_calculator.script, one for each part. For assignment 2, in your Gaul account, you should have the following files in directory ~/courses/cs2211/Asn/asn2 to be submitted: converter.c (for part one) converter.script (for part one) power2_calculator.c (for part two) power2_calculator.script (for part two) assignment_academic_consideration_form.txt (download and fill with the re- quired information if you have requested an academic consideration through faculty academic counselling) 3 Assignment overview We would like students to experience command line input with C types of character, int, float, and long, to understand and use C types such as char, int, float, and long, as well as the flow control structures studied in class, and to use functions and recursive functions. This assignment consists of two parts. In part one, you are required to write a C program to perform some simple conversions. In part two, you are to write a C program to calculate value of exponential numbers. Part one: 70% The goal of the exercise is to implement a simple converter, called "converter.c", which works as follows. (1) First, program will prompt users with the following five options and the user is asked what she/he wants to do. A single integer can be read with the following six actions associated with different values of the character. You can assume that the user will always enter a single integer. 1 for conversion between Celsius and Fahrenheit 2 for conversion between Centimetre and Inch 3 for conversion between Kilometer and Mile 4 for conversion between Gallon and Liter 0 for quit For any other integer, repeat step (1) (2) In case of 1, 2, 3, and 4, each action should be implemented as a function. In case of 0, the program will terminate. For all the other values, repeat step (1). (3) In case of 1 to 4, the program will ask the direction of the conversion. In each case, a single character can be entered whose value corresponding to each conversion direc- tion. In case of 1, the program will prompt the user for two choices and wait for a character input 1 . C for conversion from Celsius to Fahrenheit . F for conversion from Fahrenheit to Celsius . For any other character, repeat this case In case of 2, the program will prompt the user for two choices and wait for a character input . C for conversion from Centimetre to Inch . I for conversion from Inch to Centimetre For any other character, repeat this case In case of 3, the program will prompt the user for two choices and wait for a character input . K for conversion from Kilometer to Mile . M for conversion from Mile to Kilometer . For any other character, repeat this case In case of 4, the program will prompt the user for two choices and wait for a character input G for conversion from Gallon to Liter . L for conversion from Liter to gallon For any other character, repeat this case HINT: to read a character properly, your program should handle the leading white- space character, space character, tab character, and end of line, or new line, character, if any. Instead of scanf("%c", &ch);, you may consider scanf(" %c", &ch);. (4) Then the program asks for the input value, properly displays the result and returns to Step (1). The input value should be a float number and we assume the user will always enter valid numbers. Your program should prompt user and display the result to user in a descriptive manner. (5) Your program should follow good programming styles, i.e. write clear code, choose good variable names, use appropriate functions, make proper comments, and etc. 2 Part two: 30% The goal of this exercise is to implement a power of two calculator, called "power2_calculator.c" with recursive function. (1) First, the user is asked for the exponent and we assume that exponent is a non-negative integer number. If the exponent entered is 0, display the result and then terminate the program. (2) Then the power of two function is calculated using a recursive function in logarithmic time in terms of the value of the exponent inputted. The result is then displayed. Hint: for n = 0 for n > 0 2n = 2 = 1 (2/2)2 if n is even { (2(n-1)/2)2 * 2 if n is odd (3) You can assume that the user always enter an integer number for the exponent. After each calculation, go to (1). (4) You should use the unsigned long for the calculation and print of power of two num- bers. (5) Your program should follow good programming styles, i.e. write clear code, choose good variable names, use appropriate functions, make proper comments, and etc. Testing your program You should test your program by running it on Gaul. For part one, each case should be tested at least once. For part two, different exponents should be tested and you should show one exponent value, e.g. smallest, that will make the program result unreliable. Capture the screen of your testing by using script command. There should be two resulting script files, converter.script and power2_calculator.script, one for each part. For assignment 2, in your Gaul account, you should have the following files in directory ~/courses/cs2211/Asn/asn2 to be submitted: converter.c (for part one) converter.script (for part one) power2_calculator.c (for part two) power2_calculator.script (for part two) assignment_academic_consideration_form.txt (download and fill with the re- quired information if you have requested an academic consideration through faculty academic counselling) 3
Expert Answer:
Answer rating: 100% (QA)
Part One 1 Define the conversion functions c Celsius to Fahrenheit conversion float celsiusToFahrenheitfloat celsius return celsius 90 50 320 Fahrenheit to Celsius conversion float fahrenheitToCelsius... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Where will you find information about the IRS's acquiescence or nonacquiescence to a court decision? Internal Revenue Code Treasury Regulations Revenue Ruling Revenue Procedure Action on Decision
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
A charged isolated metal sphere of diameter 10 cm has a potential of 8000 V relative to V = 0 at infinity. Calculate the energy density in the electric field near the surface of the sphere.
-
A thermistor probe, in the shape of a needle parallel to the flow, reads a static temperature of 25C when inserted in the stream. A conical disturbance of half-angle 17 is formed. Estimate (a) The...
-
Consider a system of linear equations with augmented matrix A and coefficient matrix C. In each case either prove the statement or give an example showing that it is false. (a) If there is more than...
-
In the design of a chemical plant, the following costs and revenues (in the third year of production) are projected: Total depreciable capital, excluding allocated \(\$ 10,000,000\) power Allocated...
-
Use the information for Indiana Jones Corporation from BE21-9. Assume that for Lost Ark Company, the lessor, Collectibility is reasonably predictable, there are no important uncertainties concerning...
-
A physics 11 student decides to test the theory of gravity by riding his bike off a building with horizontal roof. However, being a smart student he checks his landing area and discovers that there...
-
Three entrepreneurs were looking to start a new brewpub near Sacramento, California, called Roseville Brewing Company (RBC). Brewpubs provide two products to customersfood from the restaurant segment...
-
Academic and professional writing course Exercise Directions : Create a thesis statement based on the following information. Topic 1: Education is important to have. Supports: It could enable one to...
-
Answer each of the following questions using complete sentences. Part I: Harper is shopping for a home and a mortgage for $175,800 with which to purchase this home. In her search, she was eligible...
-
Violet Inc. and Melon Inc. are competing on a supply contract. Violet Inc. ' s offer is $ 8 5 , 0 0 0 , less 1 3 % and 7 % . Melon Inc. ' s offer is $ 1 2 2 , 0 0 0 less 1 0 % and 1 0 % . a ....
-
Cristina-Carlos Company manufactures various health products. The company is contemplating continuing to make the product with a new machine or buying the finished product from an outside vendor....
-
How do microorganisms engage in inter-kingdom signaling to establish symbiotic relationships with plants, and what are the implications for agriculture and environmental remediation strategies?
-
Provide the definition of the bullwhip effect and cite your source for it. Also, in a bulleted list, identify what can mitigate the bullwhip effect and cite your source for it (it can be from the...
-
The existing posted speed limit on a section of highway is 55 mph and studies have shown that the current 65th percentile speed in 65 mph. If the posted speed finit is to be increased to the current...
-
Explain how the graph of each function can be obtained from the graph of y = 1/x or y = 1/x 2 . Then graph f and give the (a) Domain (b) Range. Determine the largest open intervals of the domain over...
-
Define a variation on StringLinkedListSelfContained from Listing 12.7 that stores objects of type Employee, rather than objects of type String. Write a program that uses this linked-list class to...
-
Write an JavaFx application for the problem described in Exercise 18. Exercise 18. Write statements that can be used in a JavaFX application to draw the five interlocking rings that are the symbol of...
-
Write a program that reads a bank account balance and an interest rate and displays the value of the account in ten years. The output should show the value of the account for three different methods...
-
A university is deciding between two meal plans. One plan charges a fixed fee of \($600\) per semester and allows students to eat as much as they want. The other plan charges a fee based on the...
-
Evaluate this statement: You are a natural athlete, an attractive person who learns easily and communicates well. Clearly, you can do everything better than your friends and acquaintances. As a...
-
In elementary school and through middle school, most students have the same teacher throughout the day and for the entire school year. Then, beginning in high school, different subjects are taught by...
Study smarter with the SolutionInn App