Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program named LastnaneFirstnamee4.c, that does the following: 1. Ask the user to enter a letter. 2. Use the getchar() function to get the

image text in transcribed

Create a program named LastnaneFirstnamee4.c, that does the following: 1. Ask the user to enter a letter. 2. Use the getchar() function to get the letter, then store the letter in a variable. 3. Print the letter to the user with useful feedback, do NOT just print the letter. 4. Clear the input stream by calling getchar() by itself, on a separate line. This is necessary because after the user enters a letter, they will hit Enter. The newline character from hitting Enter is in the input stream and will interfere with the next prompt. This is similar to Java when it is necessary to clear the Scanner 5. Ask the user to enter a second letter and store it in a variable. 6. Print the second letter to the user with useful feedback, do NOT just print the letter. 7. Run your program by compiling it with the gcc command and executing the acout file. Example Output % gcc MeyerEdward84.c %/a.out Enter a lettere The first letter is: 'e' Enter another letter: d The second letter is: 'd' Instructions (Part 2) Do NOT proceed with the rest of the program if you have not finished part 1. For this next part, you are still using the same program and adding to it, this time, to ask for numbers. To set numeric input from the user, you will need to setup your program to take in numbers using the custom getdouble() function from the example code. 8. To use the getdouble() function, you need the following three files: getdouble.c, getdouble.h, and makefile-double. Download each file by right-clicking on each link above and Save Link As... After downloading each file to your computer, upload it to your hunix account and ensure the files are in the same directory as your LastnaneFirstnane24.c program. 9. Use emacs to edit makefile-double so that it will compile and link getdouble.c, getdouble.h, and LastnaneFirstnane4.c. In other words, you want to replace all instances of inputdouble with LastnameFirstname04. As an example, here's a picture of my makefile-double after the edits: https://laulima.hawaii.edu/x/49cP99 10. Save makefile-double. 11. Back in LastnameFirstname84.C, add the following include statement at the top: Ninclude "get double.h" 12. After the code for printing the second letter, ask the user to enter a number. 13. Use the getdouble() function to get the number, then store the number in a variable. . You do not have to clear the input stream when using the custom get double() function, it is already coded to do so. 14. Print the number to the user with useful feedback. 15. Ask the user to enter a second number and store it in a variable. 16. Print the second number to the user ith feedback. 17. At the end of the main function, be sure to return 0; This applies to all assignments, regardless if it is stated in the instructions or not. Since main is declared as an int function, it should return an int at some point. It is customary to return 0; at the end of main. O is a value signaling that the program terminated successfully. Any non-zero value would indicate that the program was not successful or that an error occurred. 18. To run the program, use makefile-double to build the executable named program, then run program. See the Example Output below for the commands that are issued. 19. Be sure to have a program description at the top and in-line comments. . Be sure to have read through the assignment policy for this class. Example Output % make -f makefile-double % ./program Enter a letter: e The first letter is: 'e' Enter another letter: d The second letter is: 'd' Enter a number: 12345.6789 The first number is: 12345.678989 Enter another number: 0.123456789 The second number is: 8.123457 %./program Enter a letter: e The first letter is: 'e' Enter another letter: H The second letter is: 'H' Enter a number: 88 The first number is: 88.000000 Enter another number: 88.888 The second number is: 88.888888 %./program Enter a letter: Y The first letter is: 'Y Enter another letter: 4 The second letter is: '' Enter a number: 5.55 The first number is: 5.558820 Enter another number: 333.333333

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

Define the communication process

Answered: 1 week ago