Question

C++ //get_letter_grade.h /* Write a function gpa_to_letter_grade that returns a string and accepts a double gpa...

C++

//get_letter_grade.h

/*

Write a function gpa_to_letter_grade that returns a string and accepts a double gpa parameter

*/

//get_letter_grade.cpp

/*

Write function code for gpa_to_letter_grade that returns a string and accepts a double gpa parameter

YOU MUST USE A SWITCH STATEMENT

Given a double 3.5 returns the string A

TIP: You'll have to convert the double to an int using multiplication

Table

3.5 to 4 returns an A

3.0 to 3.49 returns a B

1.7 to 2.99 returns a C

1 to 1.69 returns a D

less than 1 returns an F

*/

//main.cpp

//Write include statements

//Write using statements

/*

No loop.

Use GPAs 3.55, 3.01, and 2.3

Three function calls and display the letter grade.

*/

int main()

{

return 0;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

//get_letter_grade.h

string gpa_to_letter_grade(double gpa);

========================

//get_letter_grade.cpp

#include <iostream>
using namespace std;
#include "get_letter_grade.h"

string gpa_to_letter_grade(double gpa)
{
string str;
if(gpa>=3.5 && gpa<=4)
str="A";
else if(gpa>=3.0 && gpa<=3.49)
str="B";
else if(gpa>=1.7 && gpa<=2.99)
str="C";
else if(gpa>=1 && gpa<=1.69)
str="D";
else if(gpa<1)
str="F";
return str;
}

===============================

// main.cpp

#include <iostream>
using namespace std;
#include "get_letter_grade.h"
int main()
{
cout<<gpa_to_letter_grade(3.55)<<endl;
cout<<gpa_to_letter_grade(3.01)<<endl;
cout<<gpa_to_letter_grade(2.3)<<endl;
  
return 0;
}

================================

output:

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
C++ //get_letter_grade.h /* Write a function gpa_to_letter_grade that returns a string and accepts a double gpa...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ clock.h /* Write a function get_hours that returns an int and accepts an int seconds_since_1970...

    C++ clock.h /* Write a function get_hours that returns an int and accepts an int seconds_since_1970 parameter */ int get_hours(int seconds_since_1970); /* Write a function get_minutes that returns an int and accepts an int seconds_since_1970 parameter */ int get_minutes(int seconds_since_1970); /* Write a function get_seconds that returns an int and accepts an int seconds_since_1970 parameter */ int get_seconds(int seconds_since_1970); clock.cpp #include "clock.h" /* Write get_hours code to return hours given seconds since 1970 int */ /* Write get_minutes code to...

  • A hard c++ problem ◎Write a c++ program”Student.h”include Private data member, string firstName; string lastName; double...

    A hard c++ problem ◎Write a c++ program”Student.h”include Private data member, string firstName; string lastName; double GPA(=(4.0*NumberOfAs+3.0*NumberOfBs+2.0*NumberOfCs+1.0*NumberOfDs)/( As+Bs+Cs+Ds+Fs)); Public data member, void setFirstName(string name); string getFirstName() const; void printFirstName() const; void getLastName(string name); string getLastName() const; void printLastName() const; void computeGPA(int NumberOfAs,int NumberOfBs,int NumberOfCs,int NumberOfDs,int NumberOfFs); double getGPA() const; double printGPA() const; A destructor and an explicit default constructor initializing GPA=0.0 and checking if GPA>=0.0 by try{}catch{}. Add member function, bool operator<(const Student); The comparison in this function based on...

  • Write a program with a function that accepts a string as an argument and returns a...

    Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed.

  • C++ Write a function named “hasDescendingDigits” that accepts a string of numbers. It returns true if...

    C++ Write a function named “hasDescendingDigits” that accepts a string of numbers. It returns true if the string contains the digits in descending order. The function can ignore (e.g. skip checking) all the characters that are not digits in the string. Empty string will return false. For example, string of “95421” or “862” or “8622” or “88” or “9” will return true and string of “95423” or “889” or “9445” or “449” or “” will return false.

  • 1. String Length Write a function that returns an integer and accepts a pointer to a...

    1. String Length Write a function that returns an integer and accepts a pointer to a C-string as an argument. The function should count the number of characters in the string and return that number. Demonstrate the function in a simple program that asks the user to input a string, passes it to the function, and then displays the function’s return value. c++

  • 1. Write a function called ordinal_sum that accepts a string argument and returns the sum of...

    1. Write a function called ordinal_sum that accepts a string argument and returns the sum of the ordinal values of each character in the string. The ordinal value of a character is its numeric Unicode code point in decimal. 2. Write code that creates a Python set containing each unique character in a string named my_string. For example, if the string is 'hello', the set would be {'h', 'e', 'l', 'o'} (in any order). Assign the set to a variable...

  • /* Write a recursive function named editDistance that accepts two string    * parameters and returns...

    /* Write a recursive function named editDistance that accepts two string    * parameters and returns the "edit distance" between the two strings as an    * integer. Edit distance (also called Levenshtein distance) is the minimum    * number of "changes" required to get from s1 to s2 or vice versa. A "change"    * is a) inserting a character,    * b) deleting a character, or    * c) changing a character to a different character.    *...

  • Write a function curve that accepts a vector v of double and returns vector after processing...

    Write a function curve that accepts a vector v of double and returns vector after processing it. First the function calculates the average of the vector and the function should then process the vector by adding the average to each element of the vector and then dividing by 2 the function should then return processed vector.

  • help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and...

    help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...

  • Write a Javascript function that accepts a string. The function takes the last digit of the...

    Write a Javascript function that accepts a string. The function takes the last digit of the ASCII code and returns a string of digits sorted in ascending order. (without using push, sort or other inbuilt function)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT