Question

In: Computer Science

GPA calculator in C language To understand the value of records in a programming language, write...

GPA calculator in C language

To understand the value of records in a programming language, write a small program in a C-based language that uses an array of structs that store student information, including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,” etc.).

Note:Code and Output Screenshots

Solutions

Expert Solution

//c code for reading students information and computing GPA based on percentage

#include<stdio.h>
struct student
{
char name[20];
int age;
float percentage;
float GPA;
char gradelevel[20];
} s[3];//store information of 3 students
int main()
{
int i;
printf("Enter information of students:\n");
// storing information
for(i=0; i<3; ++i)
{
printf("Enter name: ");
scanf("%s",s[i].name);
printf("Enter Age: ");
scanf("%d",&s[i].age);
printf("Enter percentage: ");
scanf("%f",&s[i].percentage);
printf("Enter gradelevel: ");
scanf("%s",s[i].gradelevel);

//computing GPA
if(s[i].percentage>=94)
s[i].GPA=4.0;
else if(s[i].percentage>=90&&s[i].percentage<94)
s[i].GPA= 3.7;
else if(s[i].percentage>=87&&s[i].percentage<90)
s[i].GPA= 3.3;
else if(s[i].percentage>=83&&s[i].percentage<87)
s[i].GPA= 3.0;
else if(s[i].percentage>=80&&s[i].percentage<84)
s[i].GPA= 2.7;
else if(s[i].percentage>=77&&s[i].percentage<80)
s[i].GPA= 2.3;
else if(s[i].percentage>=73&&s[i].percentage<77)
s[i].GPA= 2.0;
else if(s[i].percentage>=70&&s[i].percentage<73)
s[i].GPA= 1.7;
else if(s[i].percentage>=67&&s[i].percentage<70)
s[i].GPA= 1.3;
else if(s[i].percentage>=60&&s[i].percentage<67)
s[i].GPA= 1.0;
else
s[i].GPA=0.0;
printf("\n---------------------------------\n");
}
  
printf("Displaying Information:\n\n");
// displaying information
for(i=0; i<3; i++)
{
printf ("\n--------student :%d---------",i+1);
printf("\nName: %s",s[i].name);
printf("\nAge: %d\n",s[i].age);
printf("\npercentage: %.2f",s[i].percentage);
printf("\nGPA : %.1f",s[i].GPA);
printf("GradeLevel : %s",s[i].gradelevel);
}
return 0;
}

program without input, storing two student records and prints GPA and gradelevel

#include<string.h>
#include<stdio.h>
struct student
{
char name[20];
int age;
float percentage;
float GPA;
char gradelevel[20];
} s[3];//store information of 3 students

int main()
{
int i;
strcpy(s[0].name,"Alice");
s[0].age=23;
s[0].GPA=4.0;
strcpy(s[0].gradelevel,"freshmen");


strcpy(s[1].name,"BOB");
s[1].age=24;
s[1].GPA=3.0;
strcpy(s[1].gradelevel,"junior");

for(i=0; i<2; i++)
{
printf("\n--------student-%d---------\n",i+1);
printf("\nGPA : %.1f\n",s[i].GPA);
printf("\nGradeLevel : %s\n\n",s[i].gradelevel);
}
return 0;
}


Related Solutions

1. To understand the value of records in a programming language, write a small program in...
1. To understand the value of records in a programming language, write a small program in a C-based language that uses an array of structs that store student information, including name, age, GPA as a float, and grade level as a string (e.g., “freshmen, junior, senior” etc.). Also, write the same program in the same language without using structs. Note: Code and with output screenshots
Write a simple Calculator program using Scheme programming language. It should be able to do following...
Write a simple Calculator program using Scheme programming language. It should be able to do following operations: "+", "-", " * *, "/". the format when using the calculator function should be (calculator(operand1 operation operand2)) -> (calculator(2 + 5)) should give the output of 7.
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user to enter the three examinations ( test 1, test 2, and test 3), homework, and final project grades then calculate and display the overall grade along with a message, using the selection structure (if/else). The message is based on the following criteria: “Excellent” if the overall grade is 90 or more. “Good” if the overall grade is between 80 and 90 ( not including...
Programming in C language (not C++) Write a runction derinition for a function called SmallNumbers that...
Programming in C language (not C++) Write a runction derinition for a function called SmallNumbers that will use a while loop. The function will prompt the user to enter integers ine by one, until the user enters a negative value to stop. The function will display any integer that is less than 25. Declare and initialize any variables needed. The function takes no arguments and has a void return type.
In C programming language, write the program "3x3" in size, calculating the matrix "c = a...
In C programming language, write the program "3x3" in size, calculating the matrix "c = a * b" by reading the a and b matrices from the outside and writing on the screen?
Code in C++ programming language description about lesson Calculator (multiple, sum, dived, sub) example.
Code in C++ programming language description about lesson Calculator (multiple, sum, dived,  sub) example.
In programming C language, write a program that creates a binary tree of words to be...
In programming C language, write a program that creates a binary tree of words to be used as a spell checking device for various text files. The list of words will come from a file “words.txt”. Your program is to read through the “words.txt” file and insert the word on that line into the tree in lexicographic order (also known as Dictionary order). Words in the file will be separated by spaces. Once this is done, your program should then...
C Language - Programming Write a function that takes an array of ints, and the size...
C Language - Programming Write a function that takes an array of ints, and the size of the array – another int. It also returns a double. Call this one ‘average.’ Return a double that is the average of the values in the array. Demonstrate that it works by finding the average of an array with these values {78, 90, 56, 99, 88, 68, 92} Write a function that takes one double parameter, and returns a char. The parameter represents...
In programming C language, write a program that creates a binary tree of words to be...
In programming C language, write a program that creates a binary tree of words to be used as a spell checking device for various text files. The list of words will come from a file “words.txt”. Your program is to read through the “words.txt” file and insert the word on that line into the tree in lexicographic order (also known as Dictionary order). Words in the file will be separated by spaces. Once this is done, your program should then...
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library...
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library and dynamic memory(malloc) that multiplies two matrices together. The numbers in the matrices must be read in from a text file. The program should also check if the two matrices are capable of being multiplied together. The amount of threads used has to be dynamic. The user should be able to choose how many threads they wish to use using the command line. Finally,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT