SlideShare a Scribd company logo
1 of 4
Download to read offline
Create a C# console application for this question.You modified class Height in Problem 1. You
are asked to copy the code and add more in this program. Write four constructors for class
Height:
Version 1: Take 2 integer arguments and use them to initialize foot and inch
Version 2: Take 1 integer argument and use it to initialize foot. Set inch to 0.
Version 3: Take no arguments. Initialize foot and inchto 0.
Version 4: Take another Height object as argument. Use foot and inch of that Height object to
initialize this object’sfoot and inch.
[note: do not directly access the instance variables. Always go through the properties.]
Use the following code to test your modified class Height.
publicclassHeightTest
{
staticvoid Main(string[] args)
{
Height myHeight1 = newHeight(5, 7);
Console.WriteLine("My height 1: {0} ft. {1} in.", myHeight1.Foot, myHeight1.Inch);
Height myHeight2 = newHeight(5);
Console.WriteLine("My height 2: {0} ft. {1} in.", myHeight2.Foot, myHeight2.Inch);
Height myHeight3 = newHeight();
Console.WriteLine("My height 3: {0} ft. {1} in.", myHeight3.Foot, myHeight3.Inch);
Height myHeight4 = newHeight(myHeight1);
Console.WriteLine("My height 4: {0} ft. {1} in.", myHeight4.Foot, myHeight4.Inch);
}
}
The following is the expected output.
My height 1: 5 ft. 7 in.
My height 2: 5 ft. 0 in.
My height 3: 0 ft. 0 in.
My height 4: 5 ft. 7 in.
Press any key to continue . . .
Solution
using System;
class Height
{
private int foot;
private int inch;
public Height(int foot,int inch) //constructor with 2 arguments
{
this.foot = foot;
this.inch = inch;
}
public Height(int foot) //constructor with 1 parameter
{
this.foot = foot;
this.inch = 0;
}
public Height() //constructor with no parameter
{
this.foot = 0;
this.inch = 0;
}
public Height(Height h) //constructor with Height class object as parameter
{
this.foot = h.foot;
this.inch = h.inch;
}
public int Foot // set and get properties for foot
{
get
{
return foot;
}
set
{
foot = value;
}
}
public int Inch //set and get properties for inch
{
get
{
return inch;
}
set
{
inch = value;
}
}
}
public class HeightTest
{
static void Main(string[] args)
{
Height myHeight1 = new Height(5, 7);
Console.WriteLine("My height 1: {0} ft. {1} in.", myHeight1.Foot, myHeight1.Inch);
Height myHeight2 = new Height(5);
Console.WriteLine("My height 2: {0} ft. {1} in.", myHeight2.Foot, myHeight2.Inch);
Height myHeight3 = new Height();
Console.WriteLine("My height 3: {0} ft. {1} in.", myHeight3.Foot, myHeight3.Inch);
Height myHeight4 = new Height(myHeight1);
Console.WriteLine("My height 4: {0} ft. {1} in.", myHeight4.Foot, myHeight4.Inch);
Console.WriteLine("Press any key to continue.....");
Console.ReadLine();
}
}
output:

More Related Content

Similar to Create a C# console application for this question.You modified class.pdf

Lists and scrollbars
Lists and scrollbarsLists and scrollbars
Lists and scrollbarsmyrajendra
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersAmbarish Hazarnis
 
Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Marlon Luz
 
Getting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem SolvingGetting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem SolvingHock Leng PUAH
 
SPF Getting Started - Console Program
SPF Getting Started - Console ProgramSPF Getting Started - Console Program
SPF Getting Started - Console ProgramHock Leng PUAH
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamAnton Caceres
 
03 oo with-c-sharp
03 oo with-c-sharp03 oo with-c-sharp
03 oo with-c-sharpNaved khan
 
gUIsInterfacebuild.xml Builds, tests, and runs the pro.docx
gUIsInterfacebuild.xml      Builds, tests, and runs the pro.docxgUIsInterfacebuild.xml      Builds, tests, and runs the pro.docx
gUIsInterfacebuild.xml Builds, tests, and runs the pro.docxwhittemorelucilla
 

Similar to Create a C# console application for this question.You modified class.pdf (20)

Functional Programming with C#
Functional Programming with C#Functional Programming with C#
Functional Programming with C#
 
Lists and scrollbars
Lists and scrollbarsLists and scrollbars
Lists and scrollbars
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - Beginners
 
Awt components
Awt componentsAwt components
Awt components
 
Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2
 
C#
C#C#
C#
 
L04 Software Design 2
L04 Software Design 2L04 Software Design 2
L04 Software Design 2
 
C#2
C#2C#2
C#2
 
ASP.NET.docx
ASP.NET.docxASP.NET.docx
ASP.NET.docx
 
C# for Java Developers
C# for Java DevelopersC# for Java Developers
C# for Java Developers
 
Getting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem SolvingGetting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem Solving
 
SPF Getting Started - Console Program
SPF Getting Started - Console ProgramSPF Getting Started - Console Program
SPF Getting Started - Console Program
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Python_UNIT-I.pptx
Python_UNIT-I.pptxPython_UNIT-I.pptx
Python_UNIT-I.pptx
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
 
03 oo with-c-sharp
03 oo with-c-sharp03 oo with-c-sharp
03 oo with-c-sharp
 
gUIsInterfacebuild.xml Builds, tests, and runs the pro.docx
gUIsInterfacebuild.xml      Builds, tests, and runs the pro.docxgUIsInterfacebuild.xml      Builds, tests, and runs the pro.docx
gUIsInterfacebuild.xml Builds, tests, and runs the pro.docx
 
Creating Interface- Practice Program 6.docx
Creating Interface- Practice Program 6.docxCreating Interface- Practice Program 6.docx
Creating Interface- Practice Program 6.docx
 
C# programs
C# programsC# programs
C# programs
 

More from jacquelynjessicap166

Explain the effect of decreasing water potential on the rate of p.pdf
Explain the effect of decreasing water potential on the rate of p.pdfExplain the effect of decreasing water potential on the rate of p.pdf
Explain the effect of decreasing water potential on the rate of p.pdfjacquelynjessicap166
 
Describe the difference between a Hfr cell and a F+ cell. If an envi.pdf
Describe the difference between a Hfr cell and a F+ cell.  If an envi.pdfDescribe the difference between a Hfr cell and a F+ cell.  If an envi.pdf
Describe the difference between a Hfr cell and a F+ cell. If an envi.pdfjacquelynjessicap166
 
Describe social behavior in Termites that differs from that in ants .pdf
Describe social behavior in Termites that differs from that in ants .pdfDescribe social behavior in Termites that differs from that in ants .pdf
Describe social behavior in Termites that differs from that in ants .pdfjacquelynjessicap166
 
Consider the two monosaccharides shown below. Select all the terms th.pdf
Consider the two monosaccharides shown below. Select all the terms th.pdfConsider the two monosaccharides shown below. Select all the terms th.pdf
Consider the two monosaccharides shown below. Select all the terms th.pdfjacquelynjessicap166
 
Convert the following java code into Visual Basic code.public Bool.pdf
Convert the following java code into Visual Basic code.public Bool.pdfConvert the following java code into Visual Basic code.public Bool.pdf
Convert the following java code into Visual Basic code.public Bool.pdfjacquelynjessicap166
 
As the value of the Pearson correlation coefficient r gets smaller i.pdf
As the value of the Pearson correlation coefficient r gets smaller i.pdfAs the value of the Pearson correlation coefficient r gets smaller i.pdf
As the value of the Pearson correlation coefficient r gets smaller i.pdfjacquelynjessicap166
 
An administrator is configuring a Cisco device and has pressed the u.pdf
An administrator is configuring a Cisco device and has pressed the u.pdfAn administrator is configuring a Cisco device and has pressed the u.pdf
An administrator is configuring a Cisco device and has pressed the u.pdfjacquelynjessicap166
 
Abstract Algebra problem - Please show your work clearly! If we are .pdf
Abstract Algebra problem - Please show your work clearly! If we are .pdfAbstract Algebra problem - Please show your work clearly! If we are .pdf
Abstract Algebra problem - Please show your work clearly! If we are .pdfjacquelynjessicap166
 
What makes a plasmid a conjugative plasmid What makes a plasmid.pdf
What makes a plasmid a conjugative plasmid What makes a plasmid.pdfWhat makes a plasmid a conjugative plasmid What makes a plasmid.pdf
What makes a plasmid a conjugative plasmid What makes a plasmid.pdfjacquelynjessicap166
 
Why is the ecological systems theory (Bronfenbrenners Ecological M.pdf
Why is the ecological systems theory (Bronfenbrenners Ecological M.pdfWhy is the ecological systems theory (Bronfenbrenners Ecological M.pdf
Why is the ecological systems theory (Bronfenbrenners Ecological M.pdfjacquelynjessicap166
 
20. a. R2 is a two-dimensional subspace of R3. b. The number of varia.pdf
20. a. R2 is a two-dimensional subspace of R3. b. The number of varia.pdf20. a. R2 is a two-dimensional subspace of R3. b. The number of varia.pdf
20. a. R2 is a two-dimensional subspace of R3. b. The number of varia.pdfjacquelynjessicap166
 
What is the purpose by using different analytical tools to measure t.pdf
What is the purpose by using different analytical tools to measure t.pdfWhat is the purpose by using different analytical tools to measure t.pdf
What is the purpose by using different analytical tools to measure t.pdfjacquelynjessicap166
 
What is the importance of SHM only occurring in B cells and not in g.pdf
What is the importance of SHM only occurring in B cells and not in g.pdfWhat is the importance of SHM only occurring in B cells and not in g.pdf
What is the importance of SHM only occurring in B cells and not in g.pdfjacquelynjessicap166
 
What is Canadas comparative advantage aside from transportation an.pdf
What is Canadas comparative advantage aside from transportation an.pdfWhat is Canadas comparative advantage aside from transportation an.pdf
What is Canadas comparative advantage aside from transportation an.pdfjacquelynjessicap166
 
What are electron carriers and what do they do Provide specific exa.pdf
What are electron carriers and what do they do Provide specific exa.pdfWhat are electron carriers and what do they do Provide specific exa.pdf
What are electron carriers and what do they do Provide specific exa.pdfjacquelynjessicap166
 
Using my study in Health Care Administration, give examples of a var.pdf
Using my study in Health Care Administration, give examples of a var.pdfUsing my study in Health Care Administration, give examples of a var.pdf
Using my study in Health Care Administration, give examples of a var.pdfjacquelynjessicap166
 
A linear system is always time-invariant.SolutionNo its false. .pdf
A linear system is always time-invariant.SolutionNo its false. .pdfA linear system is always time-invariant.SolutionNo its false. .pdf
A linear system is always time-invariant.SolutionNo its false. .pdfjacquelynjessicap166
 
This chapter is quite a different read from the balance of the book..pdf
This chapter is quite a different read from the balance of the book..pdfThis chapter is quite a different read from the balance of the book..pdf
This chapter is quite a different read from the balance of the book..pdfjacquelynjessicap166
 
The ventral rami of the spinal nerves course between which muscle la.pdf
The ventral rami of the spinal nerves course between which muscle la.pdfThe ventral rami of the spinal nerves course between which muscle la.pdf
The ventral rami of the spinal nerves course between which muscle la.pdfjacquelynjessicap166
 
The disease phenylketonuria is an autosomal recessively inherited dis.pdf
The disease phenylketonuria is an autosomal recessively inherited dis.pdfThe disease phenylketonuria is an autosomal recessively inherited dis.pdf
The disease phenylketonuria is an autosomal recessively inherited dis.pdfjacquelynjessicap166
 

More from jacquelynjessicap166 (20)

Explain the effect of decreasing water potential on the rate of p.pdf
Explain the effect of decreasing water potential on the rate of p.pdfExplain the effect of decreasing water potential on the rate of p.pdf
Explain the effect of decreasing water potential on the rate of p.pdf
 
Describe the difference between a Hfr cell and a F+ cell. If an envi.pdf
Describe the difference between a Hfr cell and a F+ cell.  If an envi.pdfDescribe the difference between a Hfr cell and a F+ cell.  If an envi.pdf
Describe the difference between a Hfr cell and a F+ cell. If an envi.pdf
 
Describe social behavior in Termites that differs from that in ants .pdf
Describe social behavior in Termites that differs from that in ants .pdfDescribe social behavior in Termites that differs from that in ants .pdf
Describe social behavior in Termites that differs from that in ants .pdf
 
Consider the two monosaccharides shown below. Select all the terms th.pdf
Consider the two monosaccharides shown below. Select all the terms th.pdfConsider the two monosaccharides shown below. Select all the terms th.pdf
Consider the two monosaccharides shown below. Select all the terms th.pdf
 
Convert the following java code into Visual Basic code.public Bool.pdf
Convert the following java code into Visual Basic code.public Bool.pdfConvert the following java code into Visual Basic code.public Bool.pdf
Convert the following java code into Visual Basic code.public Bool.pdf
 
As the value of the Pearson correlation coefficient r gets smaller i.pdf
As the value of the Pearson correlation coefficient r gets smaller i.pdfAs the value of the Pearson correlation coefficient r gets smaller i.pdf
As the value of the Pearson correlation coefficient r gets smaller i.pdf
 
An administrator is configuring a Cisco device and has pressed the u.pdf
An administrator is configuring a Cisco device and has pressed the u.pdfAn administrator is configuring a Cisco device and has pressed the u.pdf
An administrator is configuring a Cisco device and has pressed the u.pdf
 
Abstract Algebra problem - Please show your work clearly! If we are .pdf
Abstract Algebra problem - Please show your work clearly! If we are .pdfAbstract Algebra problem - Please show your work clearly! If we are .pdf
Abstract Algebra problem - Please show your work clearly! If we are .pdf
 
What makes a plasmid a conjugative plasmid What makes a plasmid.pdf
What makes a plasmid a conjugative plasmid What makes a plasmid.pdfWhat makes a plasmid a conjugative plasmid What makes a plasmid.pdf
What makes a plasmid a conjugative plasmid What makes a plasmid.pdf
 
Why is the ecological systems theory (Bronfenbrenners Ecological M.pdf
Why is the ecological systems theory (Bronfenbrenners Ecological M.pdfWhy is the ecological systems theory (Bronfenbrenners Ecological M.pdf
Why is the ecological systems theory (Bronfenbrenners Ecological M.pdf
 
20. a. R2 is a two-dimensional subspace of R3. b. The number of varia.pdf
20. a. R2 is a two-dimensional subspace of R3. b. The number of varia.pdf20. a. R2 is a two-dimensional subspace of R3. b. The number of varia.pdf
20. a. R2 is a two-dimensional subspace of R3. b. The number of varia.pdf
 
What is the purpose by using different analytical tools to measure t.pdf
What is the purpose by using different analytical tools to measure t.pdfWhat is the purpose by using different analytical tools to measure t.pdf
What is the purpose by using different analytical tools to measure t.pdf
 
What is the importance of SHM only occurring in B cells and not in g.pdf
What is the importance of SHM only occurring in B cells and not in g.pdfWhat is the importance of SHM only occurring in B cells and not in g.pdf
What is the importance of SHM only occurring in B cells and not in g.pdf
 
What is Canadas comparative advantage aside from transportation an.pdf
What is Canadas comparative advantage aside from transportation an.pdfWhat is Canadas comparative advantage aside from transportation an.pdf
What is Canadas comparative advantage aside from transportation an.pdf
 
What are electron carriers and what do they do Provide specific exa.pdf
What are electron carriers and what do they do Provide specific exa.pdfWhat are electron carriers and what do they do Provide specific exa.pdf
What are electron carriers and what do they do Provide specific exa.pdf
 
Using my study in Health Care Administration, give examples of a var.pdf
Using my study in Health Care Administration, give examples of a var.pdfUsing my study in Health Care Administration, give examples of a var.pdf
Using my study in Health Care Administration, give examples of a var.pdf
 
A linear system is always time-invariant.SolutionNo its false. .pdf
A linear system is always time-invariant.SolutionNo its false. .pdfA linear system is always time-invariant.SolutionNo its false. .pdf
A linear system is always time-invariant.SolutionNo its false. .pdf
 
This chapter is quite a different read from the balance of the book..pdf
This chapter is quite a different read from the balance of the book..pdfThis chapter is quite a different read from the balance of the book..pdf
This chapter is quite a different read from the balance of the book..pdf
 
The ventral rami of the spinal nerves course between which muscle la.pdf
The ventral rami of the spinal nerves course between which muscle la.pdfThe ventral rami of the spinal nerves course between which muscle la.pdf
The ventral rami of the spinal nerves course between which muscle la.pdf
 
The disease phenylketonuria is an autosomal recessively inherited dis.pdf
The disease phenylketonuria is an autosomal recessively inherited dis.pdfThe disease phenylketonuria is an autosomal recessively inherited dis.pdf
The disease phenylketonuria is an autosomal recessively inherited dis.pdf
 

Recently uploaded

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Ư...Nguyen Thanh Tu Collection
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxMohamed Rizk Khodair
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
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 17Celine George
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
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.pptxCeline George
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
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 AppCeline George
 
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 Partnershipsexpandedwebsite
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...Nguyen Thanh Tu Collection
 
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
 
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.pptxAdelaideRefugio
 
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 HinduismDabee Kamal
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
ĐỀ 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...Nguyen Thanh Tu Collection
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 

Recently uploaded (20)

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Ư...
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
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
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
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
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
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
 
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
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
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...
 
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
 
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
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
ĐỀ 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...
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 

Create a C# console application for this question.You modified class.pdf

  • 1. Create a C# console application for this question.You modified class Height in Problem 1. You are asked to copy the code and add more in this program. Write four constructors for class Height: Version 1: Take 2 integer arguments and use them to initialize foot and inch Version 2: Take 1 integer argument and use it to initialize foot. Set inch to 0. Version 3: Take no arguments. Initialize foot and inchto 0. Version 4: Take another Height object as argument. Use foot and inch of that Height object to initialize this object’sfoot and inch. [note: do not directly access the instance variables. Always go through the properties.] Use the following code to test your modified class Height. publicclassHeightTest { staticvoid Main(string[] args) { Height myHeight1 = newHeight(5, 7); Console.WriteLine("My height 1: {0} ft. {1} in.", myHeight1.Foot, myHeight1.Inch); Height myHeight2 = newHeight(5); Console.WriteLine("My height 2: {0} ft. {1} in.", myHeight2.Foot, myHeight2.Inch); Height myHeight3 = newHeight(); Console.WriteLine("My height 3: {0} ft. {1} in.", myHeight3.Foot, myHeight3.Inch); Height myHeight4 = newHeight(myHeight1); Console.WriteLine("My height 4: {0} ft. {1} in.", myHeight4.Foot, myHeight4.Inch); } } The following is the expected output. My height 1: 5 ft. 7 in. My height 2: 5 ft. 0 in. My height 3: 0 ft. 0 in. My height 4: 5 ft. 7 in.
  • 2. Press any key to continue . . . Solution using System; class Height { private int foot; private int inch; public Height(int foot,int inch) //constructor with 2 arguments { this.foot = foot; this.inch = inch; } public Height(int foot) //constructor with 1 parameter { this.foot = foot; this.inch = 0; } public Height() //constructor with no parameter { this.foot = 0; this.inch = 0; } public Height(Height h) //constructor with Height class object as parameter { this.foot = h.foot; this.inch = h.inch; } public int Foot // set and get properties for foot { get { return foot;
  • 3. } set { foot = value; } } public int Inch //set and get properties for inch { get { return inch; } set { inch = value; } } } public class HeightTest { static void Main(string[] args) { Height myHeight1 = new Height(5, 7); Console.WriteLine("My height 1: {0} ft. {1} in.", myHeight1.Foot, myHeight1.Inch); Height myHeight2 = new Height(5); Console.WriteLine("My height 2: {0} ft. {1} in.", myHeight2.Foot, myHeight2.Inch); Height myHeight3 = new Height(); Console.WriteLine("My height 3: {0} ft. {1} in.", myHeight3.Foot, myHeight3.Inch); Height myHeight4 = new Height(myHeight1); Console.WriteLine("My height 4: {0} ft. {1} in.", myHeight4.Foot, myHeight4.Inch); Console.WriteLine("Press any key to continue....."); Console.ReadLine();