Allow the user to enter data for up to twenty students

Assignment Help Computer Engineering
Reference no: EM132211490

Question :

Write a program that uses a structure to store the following student data items:

First Name

Last Name

Student ID (10 digit integer - store as long int)

Major GPA (double)

The program should allow the user to enter data for up to twenty students, the data should be stored in an array of the structure type described above.

The program should sort the array elements in ascending order by the student's last name and first name. After sorting the array, display a table that shows the student data in a table with the following column headings in order:

Last Name, First Name, Student ID, Major and GPA.

Sample output from a program that satisfies the requirements of this exercise are provided below.

Enter the first student's first name or -1 to end input: Mary Catherine

Enter student #1's last name: Van Pelt

Enter student #1's student ID number: 2011567890

Enter student #1's major: Biomedical Science

Enter student #1's grade point average: 3.52

Enter student #2's first name or -1 to end input: Daniel

Enter student #2's last name: Smith

Enter student #2's student ID number: 2012196321

Enter student #2's major: Electrical Engineering

Enter student #2's grade point average: 3.33

Last Name First Name Student ID Major GPA

____________________________________________

Smith Daniel 2012196321 Electrical Engineering 3.33

Van Pelt Mary Catherine 2011567890 Biomedical Science 3.52

Here's what I have so far:

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define MAX 20

struct info
{
char firstName[30];
char lastName[30];
char tlastName[30];
long int studentId[10];
char major[30];
double gpa;

};

int main()
{

char hold [30];
int i, j, k, num;
struct info student[MAX];

for(i = 1;i <= MAX; i++)
{
printf("Enter student #%d's first name or -1 to end input: ", i);
gets(student[i].firstName);
printf("Enter student #%d's last name: ", i);
gets(student[i].lastName);
printf("Enter student #%d's student ID number: ", i);
scanf("%d", &student[i].studentId);
printf("Enter student #%d's major: ", i);
gets(student[i].major);
printf("Enter student #%d's grade point average: ", i);
scanf("%f", &student[i].gpa);
strcpy( student[i].tlastName, student[i].lastName);
num++;
}

for (i = 0; i < num - 1 ; i++)
{
for (j = i + 1; j < num; j++)
{
if (strcmp(student[i].lastName, student[j].lastName) > 0)
{
strcpy(hold, student[i].lastName);
strcpy(student[i].lastName, student[j].lastName);
strcpy(student[j].lastName, hold);
}
}
}

printf("Last Name\t\t\tFirst Name\t\t\tStudent ID\tMajor\t\t\tGPA\n");
printf("____________________________________________________________");

for(i = 1;i <= num; i++)
{
printf("\n");
puts(student[i].firstName);
printf("\t\t\t");
puts(tstudent[i].lastName);
printf("\t\t\t");
printf("%d\t", student[i].studentId);
printf("%s\t\t\t", student[i].major);
printf("%f", student[i].gpa);

}
getch();
return 0;
}

Reference no: EM132211490

Questions Cloud

WAP that takes as input an unordered list of integers : Write a program that takes as input an unordered list of integers, creates a Btree of minimum degree t=4 and then outputs the sorted list of integers.
Use cubic lagrange polynomials to perform interpolations : Write a program that uses cubic Lagrange polynomials to perform interpolations.
Write a program that uses structure to store the information : Write a program that uses a structure named MovieData to store the following information about a movie: Title, Director.
Write a program that writes a html table of celsius temp : The Celsius temperatures should begin at 0 degrees, and each row in the table should increment by 10 degrees C, up to a maximum Celsius value of 100.
Allow the user to enter data for up to twenty students : The program should sort the array elements in ascending order by the student's last name and first name.
Write a program for the gcd and lcm : Write a program that shows that the product of two positive integers is equal to the product of their GCD (Greatest Common Divisor) and LCM.
Write a program that reverses a text file : Write a program that reverses a text file by using a stack. The user interface must consist of 2 list boxes and 3 buttons. The 3 buttons are.
Write a program that will take a sentence : Write a program that will take a sentence (a single String) such as "the lazy dog tripped over the bar stool", picks out the individual words (substrings).
Write a program that simulates the functionality : Write a program that simulates the functionality of a vending machine having the following characteristics: The vending machine offers 5 products.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd