'F' → Fullscreen
Create a new C# program named 1-5-card, starting empty.
You are building a profile card — an athlete, a game character, a club officer, a driver, anyone with facts attached to them. Pick your own, and use real facts or invented ones.
string variable holding your subject's name.The quotes appear exactly once in your program. Everywhere else you write the variable's name.
string playerName = "Maya Okonkwo";
Console.WriteLine(playerName);Console.Write(playerName);Console.WriteLine(" is on the roster.");Maya OkonkwoMaya Okonkwo is on the roster.int, a double, and a bool, each holding a real fact about your subject.Each label needs a Console.Write and each value a Console.WriteLine. That is the pattern from Activity 1.4, and it is how a label and a stored value share one line.
// Who this card is forstring playerName = "Maya Okonkwo";int jerseyNumber = 24;double pointsPerGame = 18.4;bool isCaptain = true;
// HeaderConsole.WriteLine("=============================");Console.Write(" ");Console.WriteLine(playerName);Console.WriteLine("=============================");Console.WriteLine();
// Stat linesConsole.Write("Number: ");Console.WriteLine(jerseyNumber);Console.Write("Points per game: ");Console.WriteLine(pointsPerGame);Console.Write("Team captain: ");Console.WriteLine(isCaptain);Console.WriteLine();
// Sign-off, reusing the nameConsole.Write(playerName);Console.WriteLine(" is on the roster.");============================= Maya Okonkwo=============================
Number: 24Points per game: 18.4Team captain: True
Maya Okonkwo is on the roster.You did not touch a single output statement. If you had typed the name into each line instead, you would have made that many edits and risked missing one.
int's value. Run it. Copy the error exactly.int a value with a decimal point. Run it. Copy that error exactly too.= value from one declaration, leaving only the type and name. Run it. Copy the third error.double to a whole number and run it. Write down exactly what prints.bool and write down exactly what prints, capital letters included.Three of these are refused and two are allowed. The two that are allowed print something slightly different from what you might expect, and neither is a mistake.
The second error offers you a cast. Ignore it. We do not have casts until session 10, and reaching for one now means guessing at something that has a session of its own.
| Fact | Example value |
|---|---|
| Height in meters | 1.83 |
| Games played this season | 12 |
| Nickname | Mo |
| Currently injured | no |
| Team or guild name | Ridge Valley |
| Jersey number | 24 |
One of these is a trap. A jersey number is written with digits, but nothing about it is ever counted or measured. Decide what you would do, and be ready to defend it either way.
// Who this card is forstring playerName = "Maya Okonkwo";int jerseyNumber = 24;double pointsPerGame = 18.4;bool isCaptain = true;
// Two more facts, each stored as the type that fits itstring teamName = "Ridge Valley";int gamesPlayed = 12;
// HeaderConsole.WriteLine("=============================");Console.Write(" ");Console.WriteLine(playerName);Console.Write(" ");Console.WriteLine(teamName);Console.WriteLine("=============================");Console.WriteLine();
// Stat linesConsole.Write("Number: ");Console.WriteLine(jerseyNumber);Console.Write("Games played: ");Console.WriteLine(gamesPlayed);Console.Write("Points per game: ");Console.WriteLine(pointsPerGame);Console.Write("Team captain: ");Console.WriteLine(isCaptain);Console.WriteLine();
// Sign-off, reusing the nameConsole.Write(playerName);Console.WriteLine(" is on the roster.");============================= Maya Okonkwo Ridge Valley=============================
Number: 24Games played: 12Points per game: 18.4Team captain: True
Maya Okonkwo is on the roster.double with more decimal places than you expect it to keep, and see what prints.Before you submit, check all six:
string, one int, one double, and one bool.The last one cannot be reconstructed by reading your program. Three of those results are compiler messages and two are output that differs from what the code looks like it should produce.
Answer the following questions before submitting your work.
= value from a declaration is an error, but the declaration still named a type and a name. In your own words, what is the difference between declaring a variable and initializing it?Submit four things to the dropbox: