SlideShare a Scribd company logo
1 of 1
Download to read offline
Debugging C# Console Program. Debug the program to identify these errors and correct them to
be able to compile and run the program
Consider the following C# console program that contains four programming errors:
using System;
namespace DailyRate
{
class Program
{
static void Main(string[] args)
{
(new Program()).run();
}
void run()
{
double dailyRate = readDouble("Enter your daily rate: ");
int noOfDays = readInt("Enter the number of days: ");
writeFee(calculateFee(dailyRate, noOfDays));
}
private void writeFee(double p, int n)
{
Console.WriteLine("The consultant's fee is: {0}", p * 1.1);
}
private double calculateFee(double dailyRate, int noOfDays);
{
return dailyRate * noOfDays;
}
private double readInt(string p)
{
Console.Write(p);
string line = Console.ReadLine();
return int.Parse(line);
}
private double readDouble(int p)
{
Console.Write(p);
string line = Console.ReadLine();
return double.Parse(line);
}
}
}
Debug the program to identify these errors and correct them to be able to compile and run the
program. The corrected program should look like this:

More Related Content

Similar to Debugging C Console Program Debug the program to identify .pdf

(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
Phil Calçado
 
Labsheet 6 - FP 201
Labsheet 6 - FP 201Labsheet 6 - FP 201
Labsheet 6 - FP 201
rohassanie
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
eugeniadean34240
 

Similar to Debugging C Console Program Debug the program to identify .pdf (20)

Typescript language extension of java script
Typescript language extension of java scriptTypescript language extension of java script
Typescript language extension of java script
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
 
What's New in C# 6
What's New in C# 6What's New in C# 6
What's New in C# 6
 
Functions.pptx, programming language in c
Functions.pptx, programming language in cFunctions.pptx, programming language in c
Functions.pptx, programming language in c
 
Novidades do c# 7 e 8
Novidades do c# 7 e 8Novidades do c# 7 e 8
Novidades do c# 7 e 8
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
 
C# p3
C# p3C# p3
C# p3
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
 
Labsheet 6 - FP 201
Labsheet 6 - FP 201Labsheet 6 - FP 201
Labsheet 6 - FP 201
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#
 
Cross Platform App Development with C++
Cross Platform App Development with C++Cross Platform App Development with C++
Cross Platform App Development with C++
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
 
What’s new in .NET
What’s new in .NETWhat’s new in .NET
What’s new in .NET
 
1 c introduction
1 c introduction1 c introduction
1 c introduction
 
C# 6
C# 6C# 6
C# 6
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 

More from access2future1

The Case of Sam Sawyer Sam Sawyer was a toprated operator i.pdf
The Case of Sam Sawyer Sam Sawyer was a toprated operator i.pdfThe Case of Sam Sawyer Sam Sawyer was a toprated operator i.pdf
The Case of Sam Sawyer Sam Sawyer was a toprated operator i.pdf
access2future1
 
Second Republic Bank is a lending company that operates in t.pdf
Second Republic Bank is a lending company that operates in t.pdfSecond Republic Bank is a lending company that operates in t.pdf
Second Republic Bank is a lending company that operates in t.pdf
access2future1
 
Proporcione ejemplos de cmo Chris y Alison participaron en .pdf
Proporcione ejemplos de cmo Chris y Alison participaron en .pdfProporcione ejemplos de cmo Chris y Alison participaron en .pdf
Proporcione ejemplos de cmo Chris y Alison participaron en .pdf
access2future1
 
PLEASE HELP ME Eric Christopher Associate Director for Glo.pdf
PLEASE HELP ME Eric Christopher Associate Director for Glo.pdfPLEASE HELP ME Eric Christopher Associate Director for Glo.pdf
PLEASE HELP ME Eric Christopher Associate Director for Glo.pdf
access2future1
 
Patient Documentation Analysis Due Date Sunday 1159 pm MT.pdf
Patient Documentation Analysis Due Date Sunday 1159 pm MT.pdfPatient Documentation Analysis Due Date Sunday 1159 pm MT.pdf
Patient Documentation Analysis Due Date Sunday 1159 pm MT.pdf
access2future1
 
Please fix the following C++ code to compile correctly in Vi.pdf
Please fix the following C++ code to compile correctly in Vi.pdfPlease fix the following C++ code to compile correctly in Vi.pdf
Please fix the following C++ code to compile correctly in Vi.pdf
access2future1
 
output and explain There is Mylist There is MyArrayList pa.pdf
output and explain There is Mylist There is MyArrayList pa.pdfoutput and explain There is Mylist There is MyArrayList pa.pdf
output and explain There is Mylist There is MyArrayList pa.pdf
access2future1
 
i am trying to add the first four lines of a studenttxt int.pdf
i am trying to add the first four lines of a studenttxt int.pdfi am trying to add the first four lines of a studenttxt int.pdf
i am trying to add the first four lines of a studenttxt int.pdf
access2future1
 

More from access2future1 (20)

The following stockholders equity accounts arranged alphabe.pdf
The following stockholders equity accounts arranged alphabe.pdfThe following stockholders equity accounts arranged alphabe.pdf
The following stockholders equity accounts arranged alphabe.pdf
 
You are considering a stock investment in one of two firms .pdf
You are considering a stock investment in one of two firms .pdfYou are considering a stock investment in one of two firms .pdf
You are considering a stock investment in one of two firms .pdf
 
The Case of Sam Sawyer Sam Sawyer was a toprated operator i.pdf
The Case of Sam Sawyer Sam Sawyer was a toprated operator i.pdfThe Case of Sam Sawyer Sam Sawyer was a toprated operator i.pdf
The Case of Sam Sawyer Sam Sawyer was a toprated operator i.pdf
 
Second Republic Bank is a lending company that operates in t.pdf
Second Republic Bank is a lending company that operates in t.pdfSecond Republic Bank is a lending company that operates in t.pdf
Second Republic Bank is a lending company that operates in t.pdf
 
Researchers found that a person in a particular country spen.pdf
Researchers found that a person in a particular country spen.pdfResearchers found that a person in a particular country spen.pdf
Researchers found that a person in a particular country spen.pdf
 
QUESTION 2 internal rate of return method 14 RETURN USE N.pdf
QUESTION 2 internal rate of return method 14 RETURN  USE N.pdfQUESTION 2 internal rate of return method 14 RETURN  USE N.pdf
QUESTION 2 internal rate of return method 14 RETURN USE N.pdf
 
Question 17 Which of the following contributes directly to t.pdf
Question 17 Which of the following contributes directly to t.pdfQuestion 17 Which of the following contributes directly to t.pdf
Question 17 Which of the following contributes directly to t.pdf
 
Proporcione ejemplos de cmo Chris y Alison participaron en .pdf
Proporcione ejemplos de cmo Chris y Alison participaron en .pdfProporcione ejemplos de cmo Chris y Alison participaron en .pdf
Proporcione ejemplos de cmo Chris y Alison participaron en .pdf
 
Please Use SWISH and write the code answer each part carefu.pdf
Please Use SWISH and write the code answer each part carefu.pdfPlease Use SWISH and write the code answer each part carefu.pdf
Please Use SWISH and write the code answer each part carefu.pdf
 
PLEASE HELP ME Eric Christopher Associate Director for Glo.pdf
PLEASE HELP ME Eric Christopher Associate Director for Glo.pdfPLEASE HELP ME Eric Christopher Associate Director for Glo.pdf
PLEASE HELP ME Eric Christopher Associate Director for Glo.pdf
 
please help with the fill in the blanks Fill in the followin.pdf
please help with the fill in the blanks Fill in the followin.pdfplease help with the fill in the blanks Fill in the followin.pdf
please help with the fill in the blanks Fill in the followin.pdf
 
Patient Documentation Analysis Due Date Sunday 1159 pm MT.pdf
Patient Documentation Analysis Due Date Sunday 1159 pm MT.pdfPatient Documentation Analysis Due Date Sunday 1159 pm MT.pdf
Patient Documentation Analysis Due Date Sunday 1159 pm MT.pdf
 
Please fix the following C++ code to compile correctly in Vi.pdf
Please fix the following C++ code to compile correctly in Vi.pdfPlease fix the following C++ code to compile correctly in Vi.pdf
Please fix the following C++ code to compile correctly in Vi.pdf
 
output and explain There is Mylist There is MyArrayList pa.pdf
output and explain There is Mylist There is MyArrayList pa.pdfoutput and explain There is Mylist There is MyArrayList pa.pdf
output and explain There is Mylist There is MyArrayList pa.pdf
 
Name the hormones that influence the menstrual cycle Ident.pdf
Name the hormones that influence the menstrual cycle  Ident.pdfName the hormones that influence the menstrual cycle  Ident.pdf
Name the hormones that influence the menstrual cycle Ident.pdf
 
Mike and Carol Brady realized that their house was not big e.pdf
Mike and Carol Brady realized that their house was not big e.pdfMike and Carol Brady realized that their house was not big e.pdf
Mike and Carol Brady realized that their house was not big e.pdf
 
742 Example 743 Continued Suppose that we have iid Ber.pdf
742 Example 743 Continued Suppose that we have iid Ber.pdf742 Example 743 Continued Suppose that we have iid Ber.pdf
742 Example 743 Continued Suppose that we have iid Ber.pdf
 
Holt Enterprises recently paid a dividend D0 of 275 It .pdf
Holt Enterprises recently paid a dividend D0 of 275 It .pdfHolt Enterprises recently paid a dividend D0 of 275 It .pdf
Holt Enterprises recently paid a dividend D0 of 275 It .pdf
 
i am trying to add the first four lines of a studenttxt int.pdf
i am trying to add the first four lines of a studenttxt int.pdfi am trying to add the first four lines of a studenttxt int.pdf
i am trying to add the first four lines of a studenttxt int.pdf
 
2 Use the information above to complete the Aging of Accoun.pdf
2 Use the information above to complete the Aging of Accoun.pdf2 Use the information above to complete the Aging of Accoun.pdf
2 Use the information above to complete the Aging of Accoun.pdf
 

Recently uploaded

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
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
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
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
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
 
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
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
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
 
ĐỀ 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...
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
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
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
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
 

Debugging C Console Program Debug the program to identify .pdf

  • 1. Debugging C# Console Program. Debug the program to identify these errors and correct them to be able to compile and run the program Consider the following C# console program that contains four programming errors: using System; namespace DailyRate { class Program { static void Main(string[] args) { (new Program()).run(); } void run() { double dailyRate = readDouble("Enter your daily rate: "); int noOfDays = readInt("Enter the number of days: "); writeFee(calculateFee(dailyRate, noOfDays)); } private void writeFee(double p, int n) { Console.WriteLine("The consultant's fee is: {0}", p * 1.1); } private double calculateFee(double dailyRate, int noOfDays); { return dailyRate * noOfDays; } private double readInt(string p) { Console.Write(p); string line = Console.ReadLine(); return int.Parse(line); } private double readDouble(int p) { Console.Write(p); string line = Console.ReadLine(); return double.Parse(line); } } } Debug the program to identify these errors and correct them to be able to compile and run the program. The corrected program should look like this: