Simple C# Programming doubt (Beginner)

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2009
Posts: 3
Reputation: jonahmano is an unknown quantity at this point 
Solved Threads: 0
jonahmano jonahmano is offline Offline
Newbie Poster

Simple C# Programming doubt (Beginner)

 
-2
  #1
Oct 16th, 2009
I am building a program with Name, Roll No., Marks in different subjects, Total and Average. Just wanted some advice. Pls encourage me.


class Report


{
static void Main ()

{

string s = " ";
int a;
/*,c,d,e,f,g,h,i;*/

Console.WriteLine ("Enter the Name:");
s= Console.ReadLine ();

Console.WriteLine ("Enter the Roll No.:");
a=Convert.ToInt32(Console.ReadLine ());

/*
Marks in English:\nMarks In Hindi:\nMarks in Maths:\nMarks in Social:\nMarks in G.K.:\n");



b=Convert.ToInt32(Console.ReadLine ());
c=Convert.ToInt32(Console.ReadLine ());
d=Convert.ToInt32(Console.ReadLine ());
e=Convert.ToInt32(Console.ReadLine ());
f=Convert.ToInt32(Console.ReadLine ());
g=Convert.ToInt32(Console.ReadLine ());
h=Convert.ToInt32(Console.ReadLine ());
i=Convert.ToInt32(Console.ReadLine ());*/

}

}

When I am asked to enter name it is not coming on the side ways

it is coming like this

Enter the Name:
Jonah


I want it to come in this way

Enter the Name: Jonah


please help what I must do to make my input name to be typed just beside " Enter the Name:" instead of next line.

thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,941
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 279
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso
 
3
  #2
Oct 16th, 2009
Hi Jonahmano! This can be done very easy.
Instead of WriteLine, use Write.
WriteLine writes a string and put a extra carriage return character after, Write does not.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 3
Reputation: jonahmano is an unknown quantity at this point 
Solved Threads: 0
jonahmano jonahmano is offline Offline
Newbie Poster
 
-2
  #3
Oct 16th, 2009
ddanbe you are wrong.

I tried to change WriteLine with Write and I got a bunch of errors

My code is working so please makes changes in my code and paste it back.

Let me compile and see

thanks
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,215
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 573
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
3
  #4
Oct 16th, 2009
No, ddanbe is correct. If you use Console.Write() then read the line it will not advance the cursor to the next line. You probably made modifications to the wrong section of the code. Here are the lines in question:
  1. Console.WriteLine ("Enter the Name:");
  2. Console.WriteLine ("Enter the Roll No.:");

Change those to Console.Write(); and please be careful when telling ddanbe when is wrong. He usually isn't.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,941
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 279
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso
 
0
  #5
Oct 16th, 2009
Also notice you don't have an extra Console.ReadKey() or ReadLine() as a last statement to keep the console on the screen. Use code tags when you post code, just as sknake did.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,613
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 469
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven
 
0
  #6
Oct 16th, 2009
@jonahmano: ddanbe you are wrong.
No. He gave you a solution. Use Write Method.
  1. Console.Write("Enter Name : ");
  2. value=Console.ReadLine();
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 3
Reputation: jonahmano is an unknown quantity at this point 
Solved Threads: 0
jonahmano jonahmano is offline Offline
Newbie Poster
 
0
  #7
Oct 16th, 2009
Thanks a lot for all your help
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,215
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 573
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
0
  #8
Oct 16th, 2009
Please mark this thread as solved as danny provided a solution to your question and good luck!

If you are still having issues please post back on this thread and we will be more than happy to help you.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

Tags
c#

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC