473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

I am a new C# Programmer

Hi Guys,

I had posted awhile back that I am a new C# programmer and I have just completed my first program. It's pretty simple, but I'm having a slight problem with it. The program that I made rearranges the order of a persons name after they input it into the console. But for some reason the order of rearrangement that I set does not work the way that I want it to work. If you guys can solve my problem and tell me what I did wrong or did not do, it will be greatly appreciated. Here is my code:

using System;

namespace Name_Rearrange

{

/// <summary>

/// Name Rearranger

/// Program rearranges a persons name

/// Eric Anderson, 11.29.05

/// </summary>

class rearrange

{

static void Main(string[] args)

{

string firstname;

string middlename;

string lastname;

Console.WriteLine("Welcome to the Name Rearranger");

// Add 1 line of space here

Console.WriteLine();

Console.Write("What is your first name? ");

firstname = Console.ReadLine();

Console.Write("What is your middle name? ");

middlename = Console.ReadLine();

Console.Write("What is your last name? ");

lastname = Console.ReadLine();

// Add 1 line of space here

Console.WriteLine();

// Show rearranged name here

Console.WriteLine("{0}, {1}, {2}",firstname,middlename,lastname);

Console.WriteLine("{2}, {0}, {1}",lastname,firstname,middlename);

Console.WriteLine("{2}, {1}, {0}", lastname, middlename, firstname);
// Add 1 line of space here

Console.WriteLine();

// Ask to press enter to end

Console.WriteLine("Thank you for playing");

Console.Write("Please press the enter key to exit!");

Console.ReadLine();

}// End Main

}// End Class

}// End Namespace
--
Eric Anderson
Nov 29 '05 #1
5 1866
Eric, you need to tell us what you want it to do.

Tom Dacon
Dacon Software Consulting

"Eric Anderson" <ti*********@email.uophx.edu> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
Hi Guys,

I had posted awhile back that I am a new C# programmer and I have just
completed my first program. It's pretty simple, but I'm having a slight
problem with it. The program that I made rearranges the order of a persons
name after they input it into the console. But for some reason the order of
rearrangement that I set does not work the way that I want it to work. If
you guys can solve my problem and tell me what I did wrong or did not do, it
will be greatly appreciated. Here is my code:

using System;

namespace Name_Rearrange

{

/// <summary>

/// Name Rearranger

/// Program rearranges a persons name

/// Eric Anderson, 11.29.05

/// </summary>

class rearrange

{

static void Main(string[] args)

{

string firstname;

string middlename;

string lastname;

Console.WriteLine("Welcome to the Name Rearranger");

// Add 1 line of space here

Console.WriteLine();

Console.Write("What is your first name? ");

firstname = Console.ReadLine();

Console.Write("What is your middle name? ");

middlename = Console.ReadLine();

Console.Write("What is your last name? ");

lastname = Console.ReadLine();

// Add 1 line of space here

Console.WriteLine();

// Show rearranged name here

Console.WriteLine("{0}, {1},
{2}",firstname,middlename,lastname);

Console.WriteLine("{2}, {0},
{1}",lastname,firstname,middlename);

Console.WriteLine("{2}, {1}, {0}", lastname, middlename,
firstname);
// Add 1 line of space here

Console.WriteLine();

// Ask to press enter to end

Console.WriteLine("Thank you for playing");

Console.Write("Please press the enter key to exit!");

Console.ReadLine();

}// End Main

}// End Class

}// End Namespace
--
Eric Anderson
Nov 29 '05 #2
SP
"Eric Anderson" <ti*********@email.uophx.edu> wrote in message news:O1**************@TK2MSFTNGP11.phx.gbl...
Hi Guys,

I had posted awhile back that I am a new C# programmer and I have just completed my first program. It's pretty simple, but I'm having a slight problem with it. The program that I made rearranges the order of a persons name after they input it into the console. But for some reason the order of rearrangement that I set does not work the way that I want it to work. If you guys can solve my problem and tell me what I did wrong or did not do, it will be greatly appreciated. Here is my code:

Console.WriteLine("{0}, {1}, {2}",firstname,middlename,lastname);

Console.WriteLine("{2}, {0}, {1}",lastname,firstname,middlename);

Console.WriteLine("{2}, {1}, {0}", lastname, middlename, firstname);
You should be changing only the order of the {0}, {1}, {2} and leave firstname,middlename,lastname the same.

SP

Nov 29 '05 #3

I think you might want this:

// Show rearranged name here
Console.WriteLine("{0}, {1}, {2}", firstname, middlename, lastname);
Console.WriteLine("{0}, {1}, {2}", lastname, firstname, middlename);
Console.WriteLine("{0}, {1}, {2}", lastname, middlename, firstname);
The {0} refers to the first argument. So when it prints, it will
replace {0} with the value of the first argument.

So, if you have Console.WriteLine("{1}", a, b); then the value of b
will be printed, and a will be ignored!

Another way to do your rearranging would be:

Console.WriteLine("{0}, {1}, {2}", firstname, middlename, lastname);
Console.WriteLine("{2}, {0}, {1}", firstname, middlename, lastname);
Console.WriteLine("{2}, {1}, {0}", firstname, middlename, lastname);

That is the same as the first method.
Eric Anderson wrote:
Hi Guys,

I had posted awhile back that I am a new C# programmer and I have just
completed my first program. It's pretty simple, but I'm having a slight
problem with it. The program that I made rearranges the order of a
persons name after they input it into the console. But for some reason
the order of rearrangement that I set does not work the way that I want
it to work. If you guys can solve my problem and tell me what I did
wrong or did not do, it will be greatly appreciated. Here is my code:
using System;

namespace Name_Rearrange

{

/// <summary>

/// Name Rearranger

/// Program rearranges a persons name

/// Eric Anderson, 11.29.05

/// </summary>

class rearrange

{

static void Main(string[] args)

{

string firstname;

string middlename;

string lastname;

Console.WriteLine("Welcome to the Name Rearranger");

// Add 1 line of space here

Console.WriteLine();

Console.Write("What is your first name? ");

firstname = Console.ReadLine();

Console.Write("What is your middle name? ");

middlename = Console.ReadLine();

Console.Write("What is your last name? ");

lastname = Console.ReadLine();

// Add 1 line of space here

Console.WriteLine();

// Show rearranged name here

Console.WriteLine("{0}, {1},
{2}",firstname,middlename,lastname);

Console.WriteLine("{2}, {0},
{1}",lastname,firstname,middlename);

Console.WriteLine("{2}, {1}, {0}", lastname, middlename,
firstname);

// Add 1 line of space here

Console.WriteLine();

// Ask to press enter to end

Console.WriteLine("Thank you for playing");

Console.Write("Please press the enter key to exit!");

Console.ReadLine();

}// End Main

}// End Class

}// End Namespace
--
Eric Anderson

Nov 29 '05 #4

Console.WriteLine("{0}, {1},
{2}",firstname,middlename,lastname);

Console.WriteLine("{2}, {0},
{1}",lastname,firstname,middlename);

Console.WriteLine("{2}, {1}, {0}", lastname, middlename,
firstname);


The numbers in the brackets tells the compiler which argument in WriteLine
should be placed in that position. So, you should not change the ordering
of {0}, {1}, {2}. Just change the ordering of your arguments like this.

Console.WriteLine("{0}, {1}, {2}", firstname, middlename, lastname);

Console.WriteLine("{0}, {1}, {2}", lastname, firstname, middlename);

Console.WriteLine("{0}, {1}, {2}", lastname, middlename, firstname);
Nov 29 '05 #5
Thanks you guys!

--
Eric Anderson
"Eric Anderson" <ti*********@email.uophx.edu> wrote in message news:O1**************@TK2MSFTNGP11.phx.gbl...
Hi Guys,

I had posted awhile back that I am a new C# programmer and I have just completed my first program. It's pretty simple, but I'm having a slight problem with it. The program that I made rearranges the order of a persons name after they input it into the console. But for some reason the order of rearrangement that I set does not work the way that I want it to work. If you guys can solve my problem and tell me what I did wrong or did not do, it will be greatly appreciated. Here is my code:

using System;

namespace Name_Rearrange

{

/// <summary>

/// Name Rearranger

/// Program rearranges a persons name

/// Eric Anderson, 11.29.05

/// </summary>

class rearrange

{

static void Main(string[] args)

{

string firstname;

string middlename;

string lastname;

Console.WriteLine("Welcome to the Name Rearranger");

// Add 1 line of space here

Console.WriteLine();

Console.Write("What is your first name? ");

firstname = Console.ReadLine();

Console.Write("What is your middle name? ");

middlename = Console.ReadLine();

Console.Write("What is your last name? ");

lastname = Console.ReadLine();

// Add 1 line of space here

Console.WriteLine();

// Show rearranged name here

Console.WriteLine("{0}, {1}, {2}",firstname,middlename,lastname);

Console.WriteLine("{2}, {0}, {1}",lastname,firstname,middlename);

Console.WriteLine("{2}, {1}, {0}", lastname, middlename, firstname);
// Add 1 line of space here

Console.WriteLine();

// Ask to press enter to end

Console.WriteLine("Thank you for playing");

Console.Write("Please press the enter key to exit!");

Console.ReadLine();

}// End Main

}// End Class

}// End Namespace
--
Eric Anderson
Nov 29 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Daniel Chartier | last post by:
Hello. I work in the paper industry and we recently had someone (the original author) from within the company make a program for preventive maintenance. However, it had some bugs and we wanted...
11
by: | last post by:
What do I do? Any ideas? I went back to school after many years and finished my bachelors degree and studied programming at a local tech school. I have no great talent to return to (mainframe...
0
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.win64 This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.win64 as an unmoderated...
0
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.win64 This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.win64 as an unmoderated...
3
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.64bit This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.64bit as an unmoderated...
29
by: jeffc | last post by:
How would you answer a question like this in an interview? I'm not interested in gathering the average of folks on this forum. I'm interested in a strategy for a) evaluating yourself objectively...
5
by: jrefactors | last post by:
when people say unix programmer, does it mean they write programs in unix environment,and those programs are run in unix platform? it is not necessary they are using unix function calls? I heard...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
23
by: Steve Jorgensen | last post by:
Hi all, I'm working on a project through a consulting company, and I'm writing some database code for use in another programmer's project in Excel/VBA. The other programmer is working through...
13
by: BK | last post by:
Our .Net team has just inherited a junior programmer that we need to get up to speed as quickly as possible. Unfortunately, his skill set is largely Access with some VB6 and ASP classic...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.