Search This Blog

UI/UX Design | Web Development | Mobile Application Development

Whether you need UI/ UX design, web development services, or mobile app development services, Qaabil Digitals will be more than happy to help you. We work with top software developers, designers, and project managers. We tailor our services to suit your exact needs. We closely look at your company, listen to your story, and bring about the best ideas and solutions that can help you drive solid results. We don’t just produce work that works. We produce work that matters. Get a quote now Or Talk to us

Monday 14 November 2011

Java program that calculates table of any given number and displays in ascending or descending order (by Sara)

import java.util.*;

class table
{
public static void main (String argsp[])
{
Scanner in = new Scanner (System.in);

int a,b,c,d=0;
System.out.print ("\n\t Enter the number to print table = ");
a=in.nextInt();
System.out.print ("\n\t Enter 1 for ascending and 2 for descending order = ");
c=in.nextInt();

if (c==1)
{
System.out.println ("\n\t Table of "+a+" in ascending order ");
b=1;
while (b<=10)
{
d=b*a;
System.out.println ("\n\t "+a+" * "+b+" = "+d);
++b;
}
}
else if (c==2)
{
System.out.println ("\n\t Table of "+a+" in ascending order ");
b=10;
while (b>0)
{
d=b*a;
System.out.println ("\n\t "+a+" * "+b+" = "+d);
--b;
}
}
else
System.out.println ("\n\t Invalid number ");

}
}

Share