
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question

Transcribed Image Text:Write a function grade2number that takes a student's letter grade (A, B, C, D, F)
as a char and returns the corresponding numerical score in the GPA (4.0, 3.0, 2.0,
1.0, 0.0). You should handle the case when the student enters an invalid character
(e.g. G) by returning -1.0. Use a switch statement. The function will be called as in
the code below.
Γράψτε μία συνάρτησης grade2number> που παίρνει τον βαθμό ενός μαθητή
( A, B , C , D, F) ως χαρακτήρα (char) και επιστρέφει την αντίστοιχη αριθμητική
βαθμολογία GPA ( 4.0, 3.0, 2.0, 1.0, 0.0 ) . Θα πρέπει να χειριστείτε την περίπτωση
που ο μαθητής εισάγει μη έγκυρο χαρακτήρα ( π.χ. G) επιστρέφοντας -1.0
Χρησιμοποιήστε την εντολή switchy. Η συνάρτηση θα καλείται όπως στον
παρακάτω κδικα.
int main()
{
char grade;
cout << "Enter your letter grade: ";
cin >> grade;
cout << "The GPA score is " << grade2number (grade);
return 0;
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
Similar questions
- For this portion of the lab, you will reuse the program you wrote in Lab 4. Redesign this solution using functions. For this lab: You will define a function names main(). You will get input in the main function and pass it to the following functions: milesToKm() FahToCel() GalToLit() PoundsToKg() InchesToCm(). Each function will require that you have a local variable to store the result of the calculation. This result will then be displayed using the print statement from within the function. Part 1B: Code Use the design you created in part A. Write a complete and syntactically correct Python program. Use the IDLE programming environmentarrow_forwarda. Write a function called IsPalindrome that receives a 3-digit number and returns whether it is palindrome or not. b. Write a function, called GCD that receives two parameters n, d, and prints their greatest common divisor a. Now after you created the two functions, you have to write a main function that can call the above functions according to user choice. Write a menu that allows the user to select from the following options 1. To use the IsPalindrome function you have to enter 1. 2. To use the GCD function you have to enter 2. 3. To Exit the program you have to enter 3. [use exit(0)] Once the user select one of the above choices you have to read the value entered by the user and then to call the respective function.arrow_forwardThe function below does not work as expected: If sales is a negative number is returns 3 instead of returning 0. Please help me correct it. /*This function determines the commision percent based on the following table:Sales Commission$0 - 1000 3%1001 - 5000 4.5%5001 - 10,000 5.25%over 10,000 6%*/double Sales::detCommissionPercent() const{double commission = 0;if ( amountSold > 0){if(amountSold<= 1000) // if amountSold is between [0, 1000] commission = 3;else if(amountSold<=5000)// if amountSold is between [1001, 5000] commission = 4.5;else if(amountSold<=10000) // if amountSold is between [5001, 10000] commission = 5.25;else commission = 6;}return commission;}arrow_forward
- What benefits can you get from using a function?\arrow_forwardTODO Create the function add func to complete the following TODO (). Create the add func() function, which accepts two arguments. The function should use the + operator to add the two arguments and then return the result. For instance, 3 should be returned if the arguments' input values are 1 and 2. Likewise, "good day" should be returned if the input arguments are "good" and "day." # TODO 6.1 print(f"add_func output for 1 + 2: {add_func(1, 2)}") print(f"add_func output for good + day: {add_func('good',' day')}") todo_check([ (add_func(1,2) == 3,'add_func() did not return 3 when using input values 1 and 2.'), (add_func('good',' day') == "good day",'add_func() did not return "good day" when using input values "good" and " day"') ])arrow_forwardComplete the Funnyville High School registration program where user is prompted for her full name and the program generates email id and temporary password. Sample run: generate_EmailID: This function takes two arguments: the user’s first name and last name and creates and returns the email id as a string by using these rules: The email id is all lower case. email id is of the form “last.first@fhs.edu”. e.g. For "John Doe" it will be "doe.john@fhs.edu". See sample runs above. generate_Password: This function takes two arguments: the user’s first name and last name and generates and returns a temporary password as a string by using these rules. Assume that user's first and last names have at least 2 letters. The temporary password starts with the first 2 letters of the first name, made lower case. followed by a number which is the sum of the lengths of the first and last name (For example this number will be 7 for "John Doe" since length of "John" is 4 and length of "Doe" is…arrow_forward
- What benefits can you get from using a function?\arrow_forwardWhat benefits can you get from using a function?\arrow_forwardPlease complete the exercise as instructed and do not use global variables. Please follow the guidelines of what the solution cannot use provided in the second picture. Thank you!arrow_forward
- Write a function called ConvertToFootInchMeasure (signature below) that takes a parameter for the total inch measure. The function should return the converted measure as a formatted string (with the " and ' as appropriate). Use the following header: string ConvertToFootInchMeasure (int totalInches)/* Pre: totalInches the total number of inchesPost: The converted, formatted measure is returned */arrow_forwardHelp pleasearrow_forwardWrite a header for a function named getKey. The function should return a char and use no parameters.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY