Write a method called DisplayPersonalInfo(). This method will display your name, school, program and your favorite course. Call the DisplayPersonalInfo() method from your program Main() method Write a method called CalculateTuition(). This method will prompt the user for the number of courses that she is currently taking and then calculate and display the tuition cost. (cost = number of course * 569.99). Call the CalculateTuition() method two times from the same Main() method as in question 1.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

Method/Function/Procedure/Sub/Routine . Please use only C# programming.

Method – this is the fourth control structure we have worked with in this course. Each control structure brings some advantage to the programmer.

  • Sequence sets the framework to ensure that all the statements are processes exactly once and in order. i.e. no skips or repeats

  • Branching allows the program to perform more than one task

  • Repetition provides a structure to process a block of code possible multiple times

  • Method allows the programmer to assign a name to a block or code

The coder has the luxury to reuse blocks of code, hence the job can be done with less code. In addition, it facilitates the decomposition of a complex problem into simpler sub-tasks that can be implemented and tested separately. This is possible by attaching a name to a block of code statements and then invoking the code when required.

 

Template of a Method

[modifier] [static] «return_type» «method_name»([parameter_type-name_list])
{
statement 1;
statement 2;
}

 

Definition of a Method

/*
*This method does not require any parameter
*This method does not return a value
*/
static void DisplayPersonInfo()
{
Console.WriteLine("Narendra");
Console.WriteLine("Centennial College");
}

All method consists of a header and a body. The header includes an accessibility modifier, the static keyword, the return type, the name of the method and a parameter list enclosed within a pair of parentheses as shown in the diagram below. All the parts enclosed within square brackets are optional. However, for this part of COMP100, the static modifier is MANDATORY.

 

 

Invocation of a Method

DisplayPersonInfo();

// This method takes a string argument
Console.WriteLine("Programming is the best");



// This method returns a string value
string name = Console.ReadLine();



// The ToInt32 method takes a string argument and returns an int value
int age = Convert.ToInt32(Console.ReadLine());







 

Methods lays the foundations for building designing and using classes. Classes is integral to Object-Oriented Programming (OOP) and is a simpler approach to implementing large or complex systems. Although newer programming paradigms are better suited to concurrent programming or working with big data or incorporating Artificial Intelligence in an application, OOP is a natural way or solving for most of us humans.

 

Sample solution is available on the public drive.

I provide a menu for all of the parts. This is not required. It is more convenient to demonstrate the solution for each individual questions

Completing these exercises will be an excellent preparation for your last test. For this, you will create a single solution and add a new project for each part i.e. your final revision will consist of a single solution with a separate project for each part. The exercises are grouped into parts based on the arguments (or lack of) and the return value. The problems are graded by difficulty level so the later problems are more challenging than the earlier ones.

 



Part I ‒ Methods with an empty parameter list and do not return a value: [Questions 1-8 required]

You invoke a method by its name followed by a pair of brackets and the usual semi-colon

  1. Write a method called DisplayPersonalInfo(). This method will display your name, school, program and your favorite course. Call the DisplayPersonalInfo() method from your program Main() method

  2. Write a method called CalculateTuition(). This method will prompt the user for the number of courses that she is currently taking and then calculate and display the tuition cost. (cost = number of course * 569.99). Call the CalculateTuition() method two times from the same Main() method as in question 1.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education