61.1k views
2 votes
Write an application named [LastName]_MultiplicationTable and create a method that prompts the user for an integer value, for example 7. Then display the product of every integer from 1 through 10 when multiplied by the entered value. For example, the first three lines of the table might read 1 x 7 = 7, 2 x 7 = 14, 3 x 7 = 21. .. . ..

User Jerfin
by
5.2k points

1 Answer

5 votes

Answer:

I did this in C# & Java

Step-by-step explanation:

C#:

public static void Main(string[] args)

{

int input = Convert.ToInt32(Console.ReadLine());

Multiply(input);

}

public static int Multiply(int input)

{

int ans = 0;

for(int i =1; i<=10; i++)

{

ans = i*input;

Console.WriteLine(i + "*" + input + "=" + ans);

}

return ans;

}

Java:

public static void main(String[] args)

{

Scanner myObj = new Scanner(System.in);

int input = Integer.parseInt(myObj.nextLine());

Multiply(input);

}

public static int Multiply(int input)

{

int ans = 0;

for(int i =1; i<=10; i++)

{

ans = i*input;

System.out.println(i + "*" + input + "=" + ans);

}

return ans;

}