1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
motikmotik
3 years ago
12

Write the C program

Computers and Technology
1 answer:
VMariaS [17]3 years ago
5 0

Answer:

The program in C is as follows:

#include <stdio.h>

char turn_to_letter(double score){

   char lettergrade = 'A';

   if(score>=80){        lettergrade = 'A';    }

   else if(score>=70){        lettergrade = 'B';    }

   else if(score>=60){        lettergrade = 'C';    }

   else if(score>=50){        lettergrade = 'D';    }

   else{lettergrade = 'F';}

   return lettergrade;

}

int main(){

   int midterm, final;

   double score;

   printf("Midterm: ");    scanf("%d", &midterm);

   printf("Final: ");    scanf("%d", &final);  

   score = 0.4 * midterm + 0.6 * final;

   printf("Score: %lf\n", score);

   printf("Letter Grade: %c",turn_to_letter(score));

   return 0;

}

Explanation:

The function begins here

char turn_to_letter(double score){

This initializes lettergrade to A

   char lettergrade = 'A';

For scores above or equal to 80, grade is A

<em>    if(score>=80){        lettergrade = 'A';    }</em>

For scores above or equal to 70, grade is B

<em>    else if(score>=70){        lettergrade = 'B';    }</em>

For scores above or equal to 60, grade is C

<em>    else if(score>=60){        lettergrade = 'C';    }</em>

For scores above or equal to 50, grade is D

<em>    else if(score>=50){        lettergrade = 'D';    }</em>

Grade is F for other scores

<em>    else{lettergrade = 'F';}</em>

This returns the letter grade

   return lettergrade;

}

The main begins here

int main(){

This declares the midterm and final scores as integer

   int midterm, final;

This declares the total score as double

   double score;

These get input for midterm score

   printf("Midterm: ");    scanf("%d", &midterm);

These get input for final score

   printf("Final: ");    scanf("%d", &final);  

This calculates the total score

   score = 0.4 * midterm + 0.6 * final;

This prints the calculated total score

   printf("Score: %lf\n", score);

This calls the turn_to_letter function and prints the returned letter grade

   printf("Letter Grade: %c",turn_to_letter(score));

   return 0;

}

You might be interested in
Output from the print statement is usually written to the ______ in the form of ________
alexdok [17]

Answer:

Hope this helps :)

Explanation:

To the *processor* in the form of *binary* (or binary language)

8 0
4 years ago
Darla is going to start writing the HTML code for a web page. What would she start with?
Leya [2.2K]

Answer:

opening

Explanation:

Your answer would be opening

6 0
3 years ago
5255555555555+55555555555555/1111*99442
Marina CMI [18]

Answer:

(502763134343429265 /101)

Explanation:

7 0
4 years ago
Read 2 more answers
An independent penetration testing company is invited to test a company's legacy banking application developed for Android phone
erastovalidia [21]

2010s is the one who created the iPhone

8 0
3 years ago
Please help explain Loops question. I will give brainliest.
OLEGan [10]

Answer:

And 1 and 2 and 3

Explanation:

It is asked to display the 'and' every time, and the count is equal to 1 plus the previous count starting at zero, so it runs 3 times

7 0
2 years ago
Other questions:
  • A receiver requires 10nW as input power. If all the system losses add up to 50dB, then how much power is required from the sourc
    15·1 answer
  • Write the equivalent c++ expression for the following algebraic expressions
    11·1 answer
  • Keyshia now wants to remove the background of the image. She marks the areas she wants to keep and the areas she wants to remove
    13·2 answers
  • Which of the following statements opens the file info.txt for both input and output? a) dataFile.open("info.txt", ios::in &amp;&
    11·2 answers
  • On the Cities worksheet, click cell H13 and enter the function that calculates the total costs for the first city. Copy the func
    14·1 answer
  • “Artificial intelligence is the tool of education in the near future”. Research on the possibility of “AI technology” in scienti
    15·1 answer
  • A successful web-based strategy that helps a business spread the word about its website and products is called:
    15·1 answer
  • HELP PLEASE What is an internal part of a computer which contains all software programs installed on your computer?
    9·2 answers
  • PLEASE HELP ILL GIVE BRAINLIEST IMMEDIATLEY TO THE CORRECT ;-;
    10·1 answer
  • Use the drop-down menus to complete the sentences about the Calendar view Arrange command group.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!