Question

In: Computer Science

*Answer must be in C* Write a program as follows: a- Define a structure type named...

*Answer must be in C*

Write a program as follows:

a- Define a structure type named "student" capable of storing the name of a student (string less than 15 characters long),

homework grade as float, and exam grade as a float.

b- Create an array of students named "cats" to store the info for 50 students.

c- Create a menu (and repeatedly display the menu) with three options:

option 1: enter the info for a student.

option 2: print the info of all students, do not print structures that have no hurricane data in them

option 3: exit program

d. write code to carry out each menu option

Solutions

Expert Solution

#include <stdio.h>
#include <string.h>

//student structure
struct student
{
char name[15];
float grade;
float examGrade;
};

int main()
{
//create an array of structure
struct student cats[50];
int choice, k;
k = 0;
while(1)
{
//display menu
printf("\noption 1: enter the info for a student.");
printf("\noption 2: print the info of all students.");
printf("\noption 3: exit program");
  
//get choice from the user
printf("\n\nEnter your choice: ");
scanf("%d", &choice);
  
if(choice==1)
{
printf("\n\nEnter the name of the student: ");
scanf("%s",cats[k].name);
printf("Enter the grade: ");
scanf("%f", &cats[k].grade);
printf("Enter the exam grade: ");
scanf("%f", &cats[k].examGrade);
k++;
}
else if(choice ==2)
{
printf("\nThe student record are: ");
for(int i=0; i<k; i++)
{
//display student record
printf("\n\nName: %s", cats[i].name);
printf("\nGrade: %.2f", cats[i].grade);
printf("\nExam grade: %.2f\n", cats[i].examGrade);
}
}
else if(choice == 3)
{
break;
}
else
{
printf("\nInvalid input!");
}
  
}
return 0;
}

OUTPUT:


Related Solutions

Visual C# 2017 Write a program named Eggs that declares four variables of type int to...
Visual C# 2017 Write a program named Eggs that declares four variables of type int to hold the number of eggs produced in a month by each of four chickens, and assign a value to each variable. Sum the eggs, then display the total in dozens and eggs. For example, if the total number of eggs was 95, the output would be 95 eggs is 7 dozen and 11 eggs. Note: For final submission ensure that the total number eggs...
Programming assignment 4 : C++ Write a program to do the following: 1.Define a structure to...
Programming assignment 4 : C++ Write a program to do the following: 1.Define a structure to store a date, which includes day(int), month(int), and year(int). 2.Define a structure to store an address, which includes address(house number and street)(string), city(string), state(string), zip code (string). 3.Define a class to store the following information about a student. It should include private member variables: name(string), ID (int), date of birth (the first structure), address (the second structure), total credit earned (int), and GPA (double)....
*Answer must be in C++ and please use a Windows machine NOT IOS! Write a program...
*Answer must be in C++ and please use a Windows machine NOT IOS! Write a program as follows: Ask the user for an integer representing a number of integers to be sorted. Create an array of integers of the size provided by user. Initialize the array to zeros. Ask the user for and populate the array with user input. Output the array elements on one line separated by a space. Write a function name “supersort” that takes an integer pointer...
Write a complete java program that Define a class named sample containing: A method named division...
Write a complete java program that Define a class named sample containing: A method named division that receives two integers x and y and returns the division of the two numbers. It must handle any possible exceptions. A method named printArray that receives an array of double arr and an integer index and prints the element in the positon index. It must handle any possible exceptions. main method that recievs input from user and repeat if wrong input. Then it...
Program must be in C++! Write a program which: Write a program which uses the following...
Program must be in C++! Write a program which: Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to...
[ Write in C not C++] 1. Define a C structure Covid19Info to store the information...
[ Write in C not C++] 1. Define a C structure Covid19Info to store the information of COVID 19 cases of countries around the world. It keeps the name of the country, number of COVID 19 cases, number of deaths, current test positive rate, etc. After defining the structure, declare a variable of Covid19Info type with some initial values for Bangladesh. [8]
(MUST BE DONE IN C (NOT C++)) Instead of using two different variables, define a structure...
(MUST BE DONE IN C (NOT C++)) Instead of using two different variables, define a structure with two members; one representing the feet and the other one representing the inches. You will also use three functions; one to initialize a structure, another one to check the validity of its values and one last one to print them out. First, go ahead and define your structure. Next, declare a structure of this type inside main. Then, call your first function (this...
write a c program of an structure based on rings(jewelry)
write a c program of an structure based on rings(jewelry)
write a Program in C++ Using a structure (struct) for a timeType, create a program to...
write a Program in C++ Using a structure (struct) for a timeType, create a program to read in 2 times into structures, and call the method addTime, in the format: t3 = addTime(t1, t2); Make sure to use add the code to reset and carry, when adding 2 times. Also, display the resultant time using a function: display(t3);
Write a Python module that must satisfy the following- Define a function named rinsert. This function...
Write a Python module that must satisfy the following- Define a function named rinsert. This function will accept two arguments, the first a list of items to be sorted and the second an integer value in the range 0 to the length of the list, minus 1. This function shall insert the element corresponding to the second parameter into the presumably sorted list from position 0 to one less than the second parameter’s index.   Define a function named rinsort. This...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT