SlideShare a Scribd company logo
1 of 2
Download to read offline
C# Programming
Instructions are as follows.
I need to use the Console.ReadKey(); and Console.Clear(); in the code.
The program should take the input and then output the code similar to the way I have it written in
the code at the end of the program. The issue I have is understanding how to use
Console.ReadKey(); instead of Readline(); and then how to call the results from the name and
quote methods to display in the DisplayResults method.
Here is what I have so far, though Im sure some of it is wrong.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chapter3Program1
{
/*
* Program: Favorite Saying
* Programmer: Laura Sturgill
* Purpose: To allow user to enter their name and favorite saying resulting in an output with
this info.
*
* */
class Ch3Program1
{
static void Main(string[] args)
{
string name, quote;
name = GetName();
quote = GetQuote();
DisplayResults();
}
static string GetName()
{
Console.WriteLine("Please enter your name:");
string name = Console.ReadLine();
return name;
}
static string GetQuote()
{
Console.WriteLine("Please enter your favorite quote:");
string quote = Console.ReadLine();
return quote;
}
static void DisplayResults()
{
Console.Clear();
Console.WriteLine("><><><><><><><><><><><><><><><><><><><><");
Console.WriteLine( GetName +"'s Favorite Quote");
Console.WriteLine(GetQuote);
Console.WriteLine("><><><><><><><><><><><><><><><><><><><><");
}
}
}
Solution
First thing, replacing ReadLine() by the ReadKey() ...
Here keys entered by the user can be read by the program using this ReadKey() function since
the user enters data at console, we need to use Console.ReadKey() function which will do same
as the ReadLine()
Console.ReadKey().Key returns the current entered key by the user
Now to make a call to the name and quote method to display results in the DisplayResults()
method, there are few ways to make it happen
Variables in the main method which stores the return values from the name and quote method are
sent as attributes to the DisplayResults() method hence it can display these values.....

More Related Content

Similar to C# ProgrammingInstructions are as follows.I need to use the Cons.pdf

1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx
tarifarmarie
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 

Similar to C# ProgrammingInstructions are as follows.I need to use the Cons.pdf (20)

C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
Basics1
Basics1Basics1
Basics1
 
Overview of c#
Overview of c#Overview of c#
Overview of c#
 
C++ Constructs.pptx
C++ Constructs.pptxC++ Constructs.pptx
C++ Constructs.pptx
 
1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Structure of a C# Program
Structure of a C# ProgramStructure of a C# Program
Structure of a C# Program
 
Tutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng verTutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng ver
 
lecture1 pf.pptx
lecture1 pf.pptxlecture1 pf.pptx
lecture1 pf.pptx
 
C# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkC# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net Framework
 
Session 1
Session 1Session 1
Session 1
 
Session 1
Session 1Session 1
Session 1
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to it
 
Building Simple C Program
Building Simple  C ProgramBuilding Simple  C Program
Building Simple C Program
 
Srgoc dotnet_new
Srgoc dotnet_newSrgoc dotnet_new
Srgoc dotnet_new
 
Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
 

More from faxteldelhi

Dr. Kellie Leitch glanced at the data on wait times collected from t.pdf
Dr. Kellie Leitch glanced at the data on wait times collected from t.pdfDr. Kellie Leitch glanced at the data on wait times collected from t.pdf
Dr. Kellie Leitch glanced at the data on wait times collected from t.pdf
faxteldelhi
 
Arthur Burton established Astro Airlines in 1980; two years after th.pdf
Arthur Burton established Astro Airlines in 1980; two years after th.pdfArthur Burton established Astro Airlines in 1980; two years after th.pdf
Arthur Burton established Astro Airlines in 1980; two years after th.pdf
faxteldelhi
 
ASTRONOMY Martian polar caps, Dont Change with Martian the seas.pdf
ASTRONOMY Martian polar caps, Dont Change with Martian the seas.pdfASTRONOMY Martian polar caps, Dont Change with Martian the seas.pdf
ASTRONOMY Martian polar caps, Dont Change with Martian the seas.pdf
faxteldelhi
 
What does it mean to be alive What environmental, economic, politic.pdf
What does it mean to be alive What environmental, economic, politic.pdfWhat does it mean to be alive What environmental, economic, politic.pdf
What does it mean to be alive What environmental, economic, politic.pdf
faxteldelhi
 
What do expect to find in the cells of lobsters to explain their imm.pdf
What do expect to find in the cells of lobsters to explain their imm.pdfWhat do expect to find in the cells of lobsters to explain their imm.pdf
What do expect to find in the cells of lobsters to explain their imm.pdf
faxteldelhi
 
the following is tnac ing two items 1-a Certificate of Deposit (CD),.pdf
the following is tnac ing two items 1-a Certificate of Deposit (CD),.pdfthe following is tnac ing two items 1-a Certificate of Deposit (CD),.pdf
the following is tnac ing two items 1-a Certificate of Deposit (CD),.pdf
faxteldelhi
 

More from faxteldelhi (20)

How dose the FAA provide oversight to insure compliance of the Safet.pdf
How dose the FAA provide oversight to insure compliance of the Safet.pdfHow dose the FAA provide oversight to insure compliance of the Safet.pdf
How dose the FAA provide oversight to insure compliance of the Safet.pdf
 
For Cooperative Diversity (CD) system, please talk about its potenti.pdf
For Cooperative Diversity (CD) system, please talk about its potenti.pdfFor Cooperative Diversity (CD) system, please talk about its potenti.pdf
For Cooperative Diversity (CD) system, please talk about its potenti.pdf
 
Dr. Kellie Leitch glanced at the data on wait times collected from t.pdf
Dr. Kellie Leitch glanced at the data on wait times collected from t.pdfDr. Kellie Leitch glanced at the data on wait times collected from t.pdf
Dr. Kellie Leitch glanced at the data on wait times collected from t.pdf
 
Arthur Burton established Astro Airlines in 1980; two years after th.pdf
Arthur Burton established Astro Airlines in 1980; two years after th.pdfArthur Burton established Astro Airlines in 1980; two years after th.pdf
Arthur Burton established Astro Airlines in 1980; two years after th.pdf
 
ASTRONOMY Martian polar caps, Dont Change with Martian the seas.pdf
ASTRONOMY Martian polar caps, Dont Change with Martian the seas.pdfASTRONOMY Martian polar caps, Dont Change with Martian the seas.pdf
ASTRONOMY Martian polar caps, Dont Change with Martian the seas.pdf
 
why penicilina cant be use for walking ammonia SolutionI gu.pdf
why penicilina cant be use for walking ammonia SolutionI gu.pdfwhy penicilina cant be use for walking ammonia SolutionI gu.pdf
why penicilina cant be use for walking ammonia SolutionI gu.pdf
 
Why is a monophasic recording a better representation of overall ner.pdf
Why is a monophasic recording a better representation of overall ner.pdfWhy is a monophasic recording a better representation of overall ner.pdf
Why is a monophasic recording a better representation of overall ner.pdf
 
Which of the following are state functions (Select all that apply.) .pdf
Which of the following are state functions (Select all that apply.) .pdfWhich of the following are state functions (Select all that apply.) .pdf
Which of the following are state functions (Select all that apply.) .pdf
 
Which of the following are NOT correctly matchedprotease lipid di.pdf
Which of the following are NOT correctly matchedprotease lipid di.pdfWhich of the following are NOT correctly matchedprotease lipid di.pdf
Which of the following are NOT correctly matchedprotease lipid di.pdf
 
When add NH4OH into the solution which contains Co2+, Ni2+, Cr3+, Fe.pdf
When add NH4OH into the solution which contains Co2+, Ni2+, Cr3+, Fe.pdfWhen add NH4OH into the solution which contains Co2+, Ni2+, Cr3+, Fe.pdf
When add NH4OH into the solution which contains Co2+, Ni2+, Cr3+, Fe.pdf
 
What is the role of PL SQL and why is it important Support your ans.pdf
What is the role of PL SQL and why is it important Support your ans.pdfWhat is the role of PL SQL and why is it important Support your ans.pdf
What is the role of PL SQL and why is it important Support your ans.pdf
 
What does it mean to be alive What environmental, economic, politic.pdf
What does it mean to be alive What environmental, economic, politic.pdfWhat does it mean to be alive What environmental, economic, politic.pdf
What does it mean to be alive What environmental, economic, politic.pdf
 
What do expect to find in the cells of lobsters to explain their imm.pdf
What do expect to find in the cells of lobsters to explain their imm.pdfWhat do expect to find in the cells of lobsters to explain their imm.pdf
What do expect to find in the cells of lobsters to explain their imm.pdf
 
Using empathy when encoding a message is the most important elem.pdf
Using empathy when encoding a message is the most important elem.pdfUsing empathy when encoding a message is the most important elem.pdf
Using empathy when encoding a message is the most important elem.pdf
 
This is a definition of which type of attack A technique used to ga.pdf
This is a definition of which type of attack A technique used to ga.pdfThis is a definition of which type of attack A technique used to ga.pdf
This is a definition of which type of attack A technique used to ga.pdf
 
The left and right ventricles are referred to as systemic and pulmona.pdf
The left and right ventricles are referred to as systemic and pulmona.pdfThe left and right ventricles are referred to as systemic and pulmona.pdf
The left and right ventricles are referred to as systemic and pulmona.pdf
 
the following is tnac ing two items 1-a Certificate of Deposit (CD),.pdf
the following is tnac ing two items 1-a Certificate of Deposit (CD),.pdfthe following is tnac ing two items 1-a Certificate of Deposit (CD),.pdf
the following is tnac ing two items 1-a Certificate of Deposit (CD),.pdf
 
The first fundamental form is an intrinsic quantity. Explain what thi.pdf
The first fundamental form is an intrinsic quantity. Explain what thi.pdfThe first fundamental form is an intrinsic quantity. Explain what thi.pdf
The first fundamental form is an intrinsic quantity. Explain what thi.pdf
 
The business cycle peak associated with the Great Recession was in Se.pdf
The business cycle peak associated with the Great Recession was in Se.pdfThe business cycle peak associated with the Great Recession was in Se.pdf
The business cycle peak associated with the Great Recession was in Se.pdf
 
4. Explain the effect of temperature on the solubility of CO2 in wate.pdf
4. Explain the effect of temperature on the solubility of CO2 in wate.pdf4. Explain the effect of temperature on the solubility of CO2 in wate.pdf
4. Explain the effect of temperature on the solubility of CO2 in wate.pdf
 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 

Recently uploaded (20)

Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 

C# ProgrammingInstructions are as follows.I need to use the Cons.pdf

  • 1. C# Programming Instructions are as follows. I need to use the Console.ReadKey(); and Console.Clear(); in the code. The program should take the input and then output the code similar to the way I have it written in the code at the end of the program. The issue I have is understanding how to use Console.ReadKey(); instead of Readline(); and then how to call the results from the name and quote methods to display in the DisplayResults method. Here is what I have so far, though Im sure some of it is wrong. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Chapter3Program1 { /* * Program: Favorite Saying * Programmer: Laura Sturgill * Purpose: To allow user to enter their name and favorite saying resulting in an output with this info. * * */ class Ch3Program1 { static void Main(string[] args) { string name, quote; name = GetName(); quote = GetQuote(); DisplayResults(); } static string GetName() { Console.WriteLine("Please enter your name:"); string name = Console.ReadLine();
  • 2. return name; } static string GetQuote() { Console.WriteLine("Please enter your favorite quote:"); string quote = Console.ReadLine(); return quote; } static void DisplayResults() { Console.Clear(); Console.WriteLine("><><><><><><><><><><><><><><><><><><><><"); Console.WriteLine( GetName +"'s Favorite Quote"); Console.WriteLine(GetQuote); Console.WriteLine("><><><><><><><><><><><><><><><><><><><><"); } } } Solution First thing, replacing ReadLine() by the ReadKey() ... Here keys entered by the user can be read by the program using this ReadKey() function since the user enters data at console, we need to use Console.ReadKey() function which will do same as the ReadLine() Console.ReadKey().Key returns the current entered key by the user Now to make a call to the name and quote method to display results in the DisplayResults() method, there are few ways to make it happen Variables in the main method which stores the return values from the name and quote method are sent as attributes to the DisplayResults() method hence it can display these values.....