- # include <iostream>
-
# include <fstream>
-
# include <iomanip>
-
# include <cstdlib> // needed for exit ()
-
using namespace std;
-
-
int main()
-
{
-
ifstream inFile;
-
ofstream outFile;
-
-
inFile.open("registration.txt"); // attempt to open the file for input Student ID first
-
{
-
char registration;
-
if (!inFile.fail()) // if it does not fail, the file exists
-
cout <<"A file exits by name Registration.txt.\n"
-
<<" Do you want to continue and overwrite it\n"
-
<<" with the new information (y or n): ";
-
cin >> registration;
-
if (tolower(registration) == 'n')
-
{
-
cout << " File cannot be overwritten." << endl;
-
exit (1); // Terminate program execution
-
}
-
}
-
outFile.open("registration.txt"); // open the file for Writing
-
if (inFile.fail()) // Successfully Open or Not
-
{
-
cout << "\nThe file was not sucessfully opened try again" << endl;
-
exit (1);
-
-
cout << "The file was successfully opened for output." << endl;
-
return 0;
-
}
-
}// I/O file
now I need to know how to write the codes so i can read in upto 12 students records, calculate the registration fee, print the table of results, calculate and print average registration fee, prints out the students who has taken the most credits, and print out all of the students who have less than 12 credits in order, fewest credit first. Also, need error checking that input values of the studentID, status of residence, and status of study are specified in the valid range. Otherwise, you should report it in an error message, and continue to read the next set of data.
I need a WHILE loop to read and process all the students
MAKE SURE TO READ STUDENT ID FIRST, THE RANGE OF STUDENT ID IS BETWEEN 1 and 999. The Input file should have up to 12 student's data which I already have in put file. - STUDENT ID # RESIDENCE STUDY # of CREDITS FEE
-
-
--------------- ----------------- --------------- -------------- ------------
-
-
55 In-state Undergraduate 19 $7345
-
100 Out-of- State Graduate 13 $5233
-
974 In-state Undergraduate 8 $5235
-
196 In-state Graduate 3 $990
-
999 Out-of- State Undergraduate 18 $7213
-
100 In-state Graduate 5 $1034
-
497 In-state Undergraduate 20 $7994
-
734 Out-of- State Graduate 7 $2403
-
691 Out-of- State Undergraduate 12 $4013
-
143 In-state Graduate 21 $8034
-
555 Out-of- State Undergraduate 10 $3985
-
01 Out of Country Graduate 04 $101
-
-
THE AVERAGE REGISTRATION FEE IS : $4465
-
THE MOST CREDIT WAS 21 TAKEN BY STUDENT 143.
-
-
LESS THAN 12 CREDITS
-
196 In-State Graduate 3 $990
2 2426
BTW THIS IS C++ NOT C codes
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sue Adams |
last post by:
I actually have two issues/questions:
I have an autonumber field in an access db table that I grab and later use to update a record in another table withing the same db.
The code I use to get it from the db table is:
''Retrieve the Registration Identification Number
strRegisterID = Rs("Register_ID")
Prior to testing my code and actually...
|
by: David C |
last post by:
This is very strange. Say I have code like this. I am simply looping
through a collection object in a foreach loop.
Course course = new Course();
foreach(Student s in course.Students)
{
Console.WriteLine(s.StudentID);
}
|
by: David C |
last post by:
I posted this question, and from the replies, I get the impression that
I worded my posting very poorly, so let me try this again.
While debugging and stepping through this foreach loop
foreach(Student s in course.Students)
{
Console.WriteLine(s.StudentID);
}
|
by: emlj001 |
last post by:
I have a form that starts at page, http://www.scmeachoraldiv.org/allstate/registration/default.asp
My problem is on the page
http://www.scmeachoraldiv.org/allstate/registration/part2.asp
I have a loop for the student lines on this page that looks back to the previous page. I have realized that I need to allow the teachers to change the...
|
by: Warly girl |
last post by:
Hi
i have a qustion plz help me to understand and solve it
Phase One Problem description
You are required to implement a student registration system. The system keeps information about the students including their id, which is an automatic number issued by the system, a name, and current number of courses. It is important to keep the count...
| |
by: aemado |
last post by:
I am trying to read in several lines, each should have exactly 5 pieces of data. I am using try/catch/throw to determine if the data is in the correct format, and trying to use iss to separate the parts. However, this is my first time using both, and I am pretty certain that I am missing something obvious. Firstly, by debugging, I found that the...
|
by: andrewst |
last post by:
Originally posted by Taijixp
Ask your teacher for help.
--
Posted via http://dbforums.com
|
by: praveenaj |
last post by:
I was given to write a C program using Linked list to enter student marks, but i can't figure out how this node insertion works:
how nodes are linked with each other???
A Computer Training Institute wants to store marks of the Theory and Practical Papers of Data Structures & Algorithm. This system keeps the Registration Number and the Name...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |