Welcome to Dream.In.Code
Become a C# Expert!

Join 150,391 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,045 people online right now. Registration is fast and FREE... Join Now!




Printing Results

 
Reply to this topicStart new topic

Printing Results, printing results in c# after core code has been written

jamespierre
3 Mar, 2008 - 08:29 AM
Post #1

New D.I.C Head
*

Joined: 3 Mar, 2008
Posts: 7

i am experimenting with counting while and do while loops and what not, and i am having some trouble printing my results, the program description and the code follows

Each of 4 bowlers will enter his or her three bowling scores. Validate the user input in the range of 0 to 300. Include in the prompt the player’s number. (For example, the prompt might be: “Enter score 1 for player #1, score must be between 0 & 300”. Calculate and print the average for each player and the total points for the team.

csharp

namespace Lab3ConsoleMTT
{
class Program
{
static void Main(string[] args)
{

int bowler, scoreNumber, score;
bool isScoreValid, isNumberValid;
int[] scores = new int[4]; // total scores for each bowler
bowler = 1;
while (bowler < 5)
{
scoreNumber=1;
while (scoreNumber < 4)
{
do
{
Console.Write("Enter score {0} for player #{1},
score must be between 0 & 300 : ", scoreNumber, bowler);
isScoreValid=false;
isNumberValid=int.TryParse(Console.ReadLine(),
out score);

if (!isNumberValid) continue; // reinput score

if (score >= 0 && score <=300)
{
scores[bowler - 1] +=score;
scoreNumber++; // can now get next score, if any
isScoreValid=true;

}
}
while (!isScoreValid); // end do
///here i know i have a valid score...i should be totaling up the sum (in order to
calculate the average....

} // end inner while
///Here i am done with a player....I need to calculate and print the average
///I might have to reinitialize some variables to get ready for the next player.
///I will also have to add to totals for the final pin count...

Console.WriteLine();
bowler++; // can now get scores for next bowler,if any
} // end outer while

//here I am done with all players...print the final pin count.



}
}
}


This post has been edited by PsychoCoder: 3 Mar, 2008 - 08:46 AM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Printing Results
3 Mar, 2008 - 08:36 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Read through this tutorial on Printing in C# and it will give you a good start on your question smile.gif
User is online!Profile CardPM
+Quote Post

jamespierre
RE: Printing Results
3 Mar, 2008 - 08:43 AM
Post #3

New D.I.C Head
*

Joined: 3 Mar, 2008
Posts: 7

QUOTE(PsychoCoder @ 3 Mar, 2008 - 09:36 AM) *

Read through this tutorial on Printing in C# and it will give you a good start on your question smile.gif


i understand this stuff, but my question was printing the results of my console application to the screen, like which variables to add and which ones will display my content, i commented my code at the bottom where i was having issues
User is offlineProfile CardPM
+Quote Post

jamespierre
RE: Printing Results
3 Mar, 2008 - 09:59 AM
Post #4

New D.I.C Head
*

Joined: 3 Mar, 2008
Posts: 7

QUOTE(jamespierre @ 3 Mar, 2008 - 09:43 AM) *

QUOTE(PsychoCoder @ 3 Mar, 2008 - 09:36 AM) *

Read through this tutorial on Printing in C# and it will give you a good start on your question smile.gif


i understand this stuff, but my question was printing the results of my console application to the screen, like which variables to add and which ones will display my content, i commented my code at the bottom where i was having issues



just forget it i figured it out
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 05:53PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month