Write a program to input a positive integer. If the input is negitive print a suitable message other wise print the first seven multiples of any number.
please do it in a proper manner.
JAVA PROGRAM..
Answers
Answered by
2
import java.util.*;
class Rishabh
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the number");
int num = in.nextInt();
int i;
if(num>0)
{
System.out.println("First Seven Multiples are:");
for(i=1;i<=7;i++)
System.out.println(num*i);
}
else
{
System.out.println("Negative Integers not allowed. Please enter a positive integer. ");
}
}
}
class Rishabh
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the number");
int num = in.nextInt();
int i;
if(num>0)
{
System.out.println("First Seven Multiples are:");
for(i=1;i<=7;i++)
System.out.println(num*i);
}
else
{
System.out.println("Negative Integers not allowed. Please enter a positive integer. ");
}
}
}
Similar questions