User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,789 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 433 | Replies: 4
Reply
Join Date: Dec 2007
Posts: 3
Reputation: Kattalyst is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Kattalyst Kattalyst is offline Offline
Newbie Poster

Help Need Help With a Loop!!

  #1  
Dec 2nd, 2007
A College offers a course that prepares students for the state licensing exam for real estate brokers. Last Year, several of the students who completed this course took the licensing examination. Naturally, the college wants to know how well its students did on the exam. You have been asked to write a program to summarize the results. You have been given a list of these 10 students. Next to each name is written a 1 if the student passed the exam or a 2 if the student failed.

Your program should analyze the results of the exam as follows.

1. Input each test result (i.e., a 1 or a 2). Display the message “Enter result” on the screen each time the program requests another test result.

2. Count the number of test results of each type

3. Display a summary of the test results indicating the number of students who passed and the number of students who failed.

4. if more than 8 students passed the exam, print the message “ Raise tuition”
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Location: Home
Posts: 2,451
Reputation: zandiago is on a distinguished road 
Rep Power: 6
Solved Threads: 24
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: Need Help With a Loop!!

  #2  
Dec 2nd, 2007
Good day..you're going to have to show some effort...we don't do assignments for students...you must show some effort. But a few things:
1. To display the "Enter Result" on the screen each time, you woukd use something like this:
char again = 'y';
while (again =='y')
{
//do something
}
cout<<"Go again?(y/n):"<<endl;
cout<<"Enter Result"<<endl;
2. You use a counter to keep track of which students failed and passed.
3. To check if more than 8 students the exam, you use an if/else statement:
if (numpassed>8)
{
cout<<"Raise tuition"<<endl;
Hope this helps, but you still got ways to go!
I shot the sheriff....but I didn't shoot the deputy
Reply With Quote  
Join Date: Dec 2007
Posts: 3
Reputation: Kattalyst is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Kattalyst Kattalyst is offline Offline
Newbie Poster

Re: Need Help With a Loop!!

  #3  
Dec 2nd, 2007
Thanks So Much...I had some lines of code already but i just needed a way to implement the loops. This is actually a practice program for an exam. Thanks..You saved a life..
Reply With Quote  
Join Date: Jun 2007
Location: Home
Posts: 2,451
Reputation: zandiago is on a distinguished road 
Rep Power: 6
Solved Threads: 24
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: Need Help With a Loop!!

  #4  
Dec 2nd, 2007
Happy that i could help...in the future you could post your code, so that it could benefit the entire daniweb community!
I shot the sheriff....but I didn't shoot the deputy
Reply With Quote  
Join Date: Dec 2007
Posts: 3
Reputation: Kattalyst is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Kattalyst Kattalyst is offline Offline
Newbie Poster

Solution Re: Need Help With a Loop!!

  #5  
Dec 5th, 2007
Here's the finished program...it compiled and ran like RoadRunner..I used Dev C++ as my compiler.


//Created by Kattalyst
//2/12/07
//This Program Calculates Grades

# include <iostream>
# include <cmath>


using namespace std;

int main()
{
const int again = 10;
int result, totalGrade;
int fail=0,counta=0,count = 1;

cout<<"Welcome To Grade Score"<<endl;

do{
cout<<"Enter Result: ";
cin>>result;
count++;

if (result==1)
{
               counta++;
}
else 
{              
                fail++;
}


}while (count <= again);

cout<<endl;
cout<<"Number of Students passed = "<<counta;
cout<<endl;

cout<<"Number of Students Failed = "<<fail<<endl;

if (counta>8)
{
cout<<"Raise tuition"<<endl;
}
else 
{
cout<<"Do not Raise Tuition"<<endl;
}


system ("pause");
return 0;
}
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 9:25 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC