Created
January 27, 2019 10:16
-
-
Save jepperaskdk/3ebf335b5150ff1d5f17af8e668f2c94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int indexOf(int* arr, int size, int element) | |
{ | |
int i; | |
for (i = 0; i < size; i++) { | |
if (arr[i] == element) { | |
return i; | |
} | |
} | |
return -1; | |
} | |
int main() | |
{ | |
int id, ct, cn, cn2, ch, ch2, b; | |
int count = 4; | |
int courses[4] = { 4587, 4599, 8997, 9696 }; | |
int credit_hours[4] = { 4, 3, 1, 3 }; | |
int error = 0; | |
char a; | |
float chc, hi, co, co2, co3, co4, tp, tp2, tp3, tp4, c1, c2; | |
chc = 120.25; | |
hi = 35.00; | |
printf("Enter the Students Id:\n\t"); | |
scanf("%d", &id); | |
printf("\nEnter how may courses taken (up to 2):\n\t"); | |
scanf("%d", &ct); | |
if (ct > 2 || ct <= 0) { | |
printf("\nSorry, we can't process your request this time-invalid number of courses.\n\n\n\t\tTry again. Goodbye!\n"); | |
exit(0); | |
} | |
if (ct == 1) { | |
printf("\nEnter the course number: \n\t"); | |
scanf("%d", &cn); | |
} else { | |
printf("Enter the 2 course numbers separated by - :(like 2356-8954)\n\t"); | |
scanf("%d-%d", &cn, &cn2); | |
} | |
int index = indexOf(courses, count, cn); | |
if (index == -1) { | |
printf("\nSorry invalid entry!\n\n\n\t\tTry again!. Goodbye!\n"); | |
exit(-1); | |
} else { | |
ch = credit_hours[index]; | |
co = ch * chc; | |
} | |
if (ct == 2) { | |
int index2 = indexOf(courses, count, cn2); | |
if (index2 == -1) { | |
printf("\nSorry invalid entry!\n\n\n\t\tTry again!. Goodbye!\n"); | |
exit(-1); | |
} else { | |
ch2 = credit_hours[index2]; | |
co2 = ch2 * chc; | |
} | |
} | |
printf("\t\t\tVALENCIA COMMUNITY COLLEGE\n\t\t\tORLANDO FL 10101\n"); | |
printf("\t\t\t*************************\n\n"); | |
printf("\t\t\tFee Invoice Prepared for Student V%d \n\n", id); | |
printf("\t\t\t1 Credit Hour = $%.2f\n\n", chc); | |
printf("\t\t\tCRN\t\tCREDIT HOURS\n"); | |
tp = hi + co; | |
printf("\t\t\t%d\t\t%d\t\t $%.2f", cn, ch, co); | |
if (ct == 2) { | |
tp = tp + co2; | |
printf("\n\t\t\t%d\t\t%d\t\t $%.2f", cn2, ch2, co2); | |
} | |
printf("\n\n\t\t\t\t\tHealth & id fees $ %.2f\n\n", hi); | |
printf("\t\t\t----------------------------------------"); | |
printf("\n\t\t\t\t\tTotal Payments \t $%.2f\n\n", tp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment