C Programming
The C program for the required functionalities is given below:
#include <stdio.h>
#include<stdlib.h>
int CRN[] = {4587, 4599, 8997, 9696, 7895, 9658, 4287, 9599,
8927, 7696, 7890, 9008};
char course[][10] = {"MAT 236", "COP 220", "GOL 124", "COP 100",
"MNT 125", "OPT 120",
"MAT 836", "COP 220", "GOM 124", "COT 100", "MOT 125", "OPT
520"};
int credit_hours[] = {4, 3, 1, 3, 2, 3, 4, 3, 1, 4, 3, 5};
int courses_taken[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int count = 0;
void displayCourses()
{
int i;
printf("\nCRN\tCourse\tCredit Hours\n");
for(i=0; i<12; i++)
printf("%d\t%s\t%d\n", CRN[i], course[i], credit_hours[i]);
}
int isCrnACourse(int x)
{
int i;
for(i=0; i<12; i++)
if(CRN[i]==x)
return i;
return -1;
}
int alreadyTaken(int x)
{
int i;
for(i=0; i<count; i++)
if(courses_taken[i]==x)
return i;
return -1;
}
void addCourse()
{
char ch;
int course_number, a;
printf("\nWould you like to print the list of courses? (y/n):
");
scanf("%c", &ch);
if(ch=='y' || ch=='Y')
displayCourses();
printf("\nEnter the course number to add : ");
scanf("%d", &course_number);
if(isCrnACourse(course_number) == -1)
printf("\nThis crn isn't valid!\n");
else
{
a = alreadyTaken(course_number);
if(a>=0)
printf("\nCourse already taken.\n");
else
{
courses_taken[count] = course_number;
count++;
printf("\nCourse added\n");
}
}
}
void dropCourse()
{
int course_number, a, b, i;
printf("\nEnter the crn to delete: ");
scanf("%d", &course_number);
b = isCrnACourse(course_number);
if(b == -1)
printf("\nThis crn isn't valid!\n");
else
{
a = alreadyTaken(course_number);
if(a==-1)
printf("\nThe student isn't taking %d/%s/%d\n", CRN[b], course[b],
credit_hours[b]);
else
{
for (i=a; i<count-1; i++)
courses_taken[i] = courses_taken[i+1];
count--;
printf("\nCourse dropped\n");
}
}
}
void printFee(int id)
{
int i, index;
float total = 0;
printf("\n\nVALENCE COMMUNITY COLLEGE");
printf("\nORLANDO FL 10101");
printf("\n-------------------------");
printf("\n\nFee Invoice Prepared for Student:");
printf("\n%d", id);
printf("\n\n1 Credit Hour = $120.25");
printf("\nCRN\tCR_PREFIX\tCR_HOURS\n");
for(i=0; i<count; i++)
{
index = isCrnACourse(CRN[i]);
printf("%d\t%s\t%d\t$ %f\n", CRN[index], course[index],
credit_hours[index], (120.25*credit_hours[index]));
total += (120.25*credit_hours[index]);
}
printf("\n\t\tHealth & id fees\t$ 35.00");
printf("\n\n-----------------------------------");
printf("\n\t\tTotal Payments\t$ %f", (total + 35.00));
}
int main(void)
{
int id, choice;
printf("Welcome!\n");
printf("Enter the student's id number: ");
scanf("%d", &id);
while(1)
{
printf("\n\nChoose from the following options:\n");
printf("\t1- Add a course for the student\n");
printf("\t2- Drop a course for the student\n");
printf("\t3- Print the fee invoice\n");
printf("\t0- Exit program\n");
printf("\nEnter your selection: ");
scanf("%d", &choice);
switch(choice)
{
case 0: printf("Exiting the program!");
exit(0);
case 1: addCourse();
break;
case 2: dropCourse();
break;
case 3: printFee(id);
break;
default: printf("Wrong choice");
break;
}
}
return 0;
}
There are 6 functions in the program(excluding main()):
There are 5 global variables:
The main() function takes as input the student id and displays the main menu repeatedly until the user doesn't decide to exit the program by choosing 0 in the main menu. Depending on the choice of the user, the corresponding functions are called. The switch-case is used for implementing the menu part of the program.
The above code is absolutely error-free and works in exactly the same manner as mentioned in the question, producing the same output.
Hope it helped. If you have any queries or doubts, please feel free to ask in the comments section. If it helped in any way, please consider giving positive ratings.
Please read the sample runs carefully as this is quite different from the previous projects. In t...
The homework assignment is to write a fee invoice using C. It
must follow the guidelines posted in the question and run as the
sample run given. Here is the question and sample run below
Please read the sample runs carefully as this is quite different
from the previous projects. In this project, the student can take
as many courses as permitted. The list of courses to take are
listed below. This time there is no restriction on the total...
Written in C, if you are able to provide comments so I can learn as I practice that would be amazing! Thank you! Learning Outcomes: Selection structures and Loops Read carefully before you start coding! At Valence community college, a student can’t take more than 3 courses under the constraint of having no more than 7 credit hours. The purpose of this assignment is to construct a fee invoice for a student. This requires the input of Student’s id as...
Please have the code run as shown in the sample run. Use as many
functions as possible and make the main function as clean as
possible. Use C for language
The purpose of this project is to create a fee invoice application for students attending Valence Community College. The main menu for your application must have the following options. 1- Add a new student 2- Add/Delete a course for a student 3- Search for a student 4- Print fee invoice...
You are asked to build and test the following system using Java and the object-oriented concepts you learned in this course: Project (20 marks) CIT College of Information technology has students, faculty, courses and departments. You are asked to create a program to manage all these information's. Create a class CIT to represents the following: Array of Students, each student is represented by class Student. Array of Faculty, each faculty is represented by class Faculty. Array of Course, each course...
In C++
Write a menu driven C++ program to read a file containing
information for a list of Students, process the data, then present
a menu to the user, and at the end print a final report shown
below. You may(should) use the structures you developed for the
previous assignment to make it easier to complete this assignment,
but it is not required.
Required Menu Operations are:
Read Students’ data from a file to update the list (refer to
sample...
Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1 to the Office of Registrar at the end of the semester. Display an introductory paragraph for the user then prompt the user to enter a student record (student ID number and five exam-scores – all on one line). The scores will be in the range of 0-100. The sentinel value of -1 will be used to mark the end of data. The instructor has...
please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...
Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required. Project Requirements Develop a text...
HELLO, PLEASE TAKE TIME TO ANSWER THIS QUESTION. PLESE ENSURE ITS CORRECT AND SHOW THAT THE PROGRAM RUNS. Task 1: Enforcing const-ness throughout Your first job will be to go through all of the code and decide which functions should be declared const. You should find several places throughout the program where this makes sense. We will also make the id data member in the Customer class const , as once a customer has been created their ID will never...
Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview For this assignment, write a program that will calculate the quiz average for a student in the CSCI 240 course. The student's quiz information will be needed for later processing, so it will be stored in an array. For the assignment, declare one array that will hold a maximum of 12 integer elements (ie. the quiz scores). It is recommended that this program be...