Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Create a method that: receives no parameter asks the user for a number Rememb

ID: 3902111 • Letter: 1

Question

1. Create a method that: receives no parameter asks the user for a number Remember that the Console.ReadLine() method gives you a string. returns the number as an integer

2. Create a method that: Receives a number (the one you returned from #1) as a parameter Add one to the number return the number that you added one to it

3. Create a method that: Receives the number as parameter (the one you returned from method #2) Prints “I heart this class” on a loop Use the number as the length of the loop

This is for C# Thank you

Explanation / Answer

using System;

public class Test
{
public static void Main()
{
int number = method1();

Console.WriteLine("Number = "+number);

method2(number);

Console.WriteLine("Increment number by 1 = "+method2(number));

Console.WriteLine("Displaying message "+number+" times");
method3(number);

}
public static int method1()
{
  Console.WriteLine("Enter the number : ");
  int number = Convert.ToInt32(Console.ReadLine());
  
  return number;
}
public static int method2(int number)
{
  return (number +1);
}
public static void method3(int number)
{
  for(int i=1;i<=number;i++)
  Console.WriteLine("I heart this class");
}
}

Output:

Enter the number :
Number = 22
Increment number by 1 = 23
Displaying message 22 times
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class
I heart this class

Do ask if any doubt. Please upvote.