Question

In: Computer Science

Student Structure Assignment Create a Student Structure globally consisting of student ID, name, completed credits, and...

Student Structure Assignment

Create a Student Structure globally consisting of student ID, name, completed credits, and GPA.

Define one student in main() and initialize the student with data.

Display all of the student’s data on one line separated by tabs.

Create another student in main().

Assign values to your second student (do not get input from the user).

Display the second student’s data on one line separated by tabs.

Create a third student in main().

Use a series of prompts to allow user to enter in all data for your third student.

Display the third student’s data on one line separated by tabs.

Create an array of 3 students.

Send the array to a function that will use a series of prompts to allow user to enter in all data using a loop.

From main(), send the array to another function that will print the students data in your array.

I want the program to work but I need one or two mistake.

Solutions

Expert Solution

Code:

#include <stdio.h>

#include<string.h>

//structure as asked in question

struct Student{

char Id[20];

char Name[50];

int cc;

char gpa[3];

};

void fill_students(struct Student arr[],int n){

//use a series of prompts to allow user to enter in all data using a loop.

for(int i=0;i<n;i++){

printf("Enter Student Id: ");

scanf("%s",arr[i].Id);

printf("Enter Student Name: ");

scanf("%s",arr[i].Name);

printf("Enter Student completed credits: ");

scanf("%d",&arr[i].cc);

printf("Enter Student gpa: ");

scanf("%s",arr[i].gpa);

printf("\n");

}

}

void print_students(struct Student arr[],int n){

//use a series of prompts to allow user to enter in all data using a loop.

for(int i=0;i<n;i++){

printf("%s\t%s\t%d\t%s\n",arr[i].Id,arr[i].Name,arr[i].cc,arr[i].gpa);

}

}

int main(void) {

//Defined one student in main() and initialize the student with data.

struct Student s1;

strcpy(s1.Id,"SN091551");

strcpy(s1.Name,"Sofia");

s1.cc=45;

strcpy(s1.gpa,"A+");

//Display all of the student’s data on one line separated by tabs

printf("%s\t%s\t%d\t%s\n",s1.Id,s1.Name,s1.cc,s1.gpa);

//Create another student in main().

struct Student s2;

//Assign values to your second student (do not get input from the user).

strcpy(s2.Id,"SN091552");

strcpy(s2.Name,"Samantha");

s2.cc=40;

strcpy(s2.gpa,"B+");

//Display the second student’s data on one line separated by tabs.

printf("%s\t%s\t%d\t%s\n",s2.Id,s2.Name,s2.cc,s2.gpa);

//Create a third student in main().

struct Student s3;

//Use a series of prompts to allow user to enter in all data for your third student.

printf("\nEnter Student Id: ");

scanf("%s",s3.Id);

printf("Enter Student Name: ");

scanf("%s",s3.Name);

printf("Enter Student completed credits: ");

scanf("%d",&s3.cc);

printf("Enter Student gpa: ");

scanf("%s",s3.gpa);

//Display the third student’s data on one line separated by tabs.

printf("\n%s\t%s\t%d\t%s\n",s3.Id,s3.Name,s3.cc,s3.gpa);

//Create an array of 3 students.

struct Student s_arr[3];

//Send the array to a function that will

fill_students(s_arr,3);

//send the array to another function that will print the students data in your array.

print_students(s_arr,3);

return 0;

}

Sample run:

SN091551    Sofia   45 A+
SN091552    Samantha    40 B+

Enter Student Id: SN091553
Enter Student Name: Sharan
Enter Student completed credits: 38
Enter Student gpa: B+

SN091553    Sharan 38 B+
Enter Student Id: SN091554
Enter Student Name: Salim
Enter Student completed credits: 35
Enter Student gpa: C+

Enter Student Id: SN091555
Enter Student Name: Salina
Enter Student completed credits: 30
Enter Student gpa: C

Enter Student Id: SN091556
Enter Student Name: Simon
Enter Student completed credits: 28
Enter Student gpa: D

SN091554    Salim   35 C+
SN091555    Salina 30 C
SN091556    Simon   28 D


Related Solutions

BUSD 1013 – Introduction to Management – Assignment Template Name: Student ID: Note: see assignment description...
BUSD 1013 – Introduction to Management – Assignment Template Name: Student ID: Note: see assignment description in Moodle – sections 9,10 should be a maximum of 2 pages Section 9: Operations plan Reference course materials – Key Items to Consider How will I ensure we have efficient operations to maximize our resources and keep costs competitive? How will I ensure customers find it easy to do business with my company (from learning about us, booking orders, scheduling, using our services...
Q3. Create a Company trading computer accessories with your Student ID & Name, address, College Email...
Q3. Create a Company trading computer accessories with your Student ID & Name, address, College Email ID and phone number for the year ended 31st Mar, 2020, and enter the following transactions using appropriate vouchers in Tally ERP 9 software: (3 Marks + 7 Marks) 1st Jan 2020, Started his business with an investment of RO 45,000 in cash. 2nd Jan 2020, Purchases computer accessories of RO 20,000 on credit from Mr. Salim. 31st Jan 2020, Sold computer accessories worth...
Q3. Create a Company trading computer accessories with your Student ID & Name, address, College Email...
Q3. Create a Company trading computer accessories with your Student ID & Name, address, College Email ID and phone number for the year ended 31st Mar, 2020, and enter the following transactions using appropriate vouchers in Tally ERP 9 software: (3 Marks + 7 Marks) 1st Jan 2020, Started his business with an investment of RO 45,000 in cash. 2nd Jan 2020, Purchases computer accessories of RO 20,000 on credit from Mr. Salim. 31st Jan 2020, Sold computer accessories worth...
In this create a code that will drop a student by ID number //////////////////////////////////////////////////////////////////////// import java.util.Scanner;...
In this create a code that will drop a student by ID number //////////////////////////////////////////////////////////////////////// import java.util.Scanner; public class COurseCom666 {     private String courseName;     private String [] students = new String[1];     private int numberOfStudents;     public COurseCom666(String courseName) {         this.courseName = courseName;     }     public String[] getStudents() {         return students;     }     public int getNumberOfStudents() {         return numberOfStudents;     }     public String getCourseName() {         return courseName;     }     public void...
Create a view named ReservationCustomer_VW. It consists of the reservation ID, trip ID, trip name, trip...
Create a view named ReservationCustomer_VW. It consists of the reservation ID, trip ID, trip name, trip date, customer number, customer last name, customer first name, and phone number for trips whose guide is Glory Unser or Susan Kiley. Show the SQL Server code for this view.
Student Name and ID no. _________________________________________________________ Write the journal entries in the given table for below...
Student Name and ID no. _________________________________________________________ Write the journal entries in the given table for below transactions of Clean Corporation during June 2020. 1 Provided services to customers on account for $650. 2 Purchased a building using 10 year Note Payable for $200,000. 3 Paid salaries to employees, $2,600. 4 Received payment from customers to whom service was given in transaction 1 5 Paid $400 dividends to shareholders. Answer Accounts Debit Credit 1 2 3 4 5
***IN C++*** Create student structure with the following fields:  Name (cstring or null-terminated character array)...
***IN C++*** Create student structure with the following fields:  Name (cstring or null-terminated character array)  Student ID (int – unique random value between 1000 and 9999)  grade (char – Values A thru F)  birthday (myDate – random value: range 1/1/2000 to 12/31/2005)  Home Town (string) Create an array of pointers to students of size 10. Example: Student *stuPtr[10]; Write a function that populates the array with 10 students. Example: populate(stuPtr); Write a display function that...
Change program linkedListClass to the linked list for student items (a student item contains id, name...
Change program linkedListClass to the linked list for student items (a student item contains id, name and score, where the id is used as key) and test it in the main method. You can define a student item using a class of student. given the following codes; import java.util.*; public class linkedListClass {    public Node header;    public linkedListClass()    {        header = null;    }    public final Node Search(int key)    {        Node...
write an assignment 300 words on retailing and wholesaling -choose a name that can be globally...
write an assignment 300 words on retailing and wholesaling -choose a name that can be globally recognized and discuss about the retailing and wholesaling in it
Create a class named Student. Student has fields for an ID number, number of credit hours...
Create a class named Student. Student has fields for an ID number, number of credit hours earned, and number of points earned. (For example, many schools compute grade point averages based on a scale of 4, so a three-credit-hour class in which a student earns an A is worth 12 points.) Include methods to assign values to all fields. Student also has a field for grade point average. Include a method to compute the grade point average field by dividing...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT