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 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
"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
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 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);
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
| |