import java.util.Scanner;
public class ConditionalSwitch {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
int a,b,c=1;
System.out.println("First number must be 1 to 5 and second from 1 to 100");
System.out.print("Enter first number = ");
a=in.nextInt();
System.out.print("Enter second number = ");
b=in.nextInt();
switch(a)
{
case 1:
if (b<100 && b>1)
{
c = a * b;
System.out.println("Product of both numbers = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
case 2:
if (b<100 && b>1)
{
c = a + b;
System.out.println("Sum of both numbers = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
case 3:
if (b<100 && b>1)
{
c = a - b;
System.out.println(""+a+" - "+b+" = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
case 4:
if (b<100 && b>1)
{
c = a / b;
System.out.println(""+a+" / "+b+" = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
case 5:
if (b<100 && b>1)
{
c = b % a;
System.out.println("Remainder of "+b+" / "+a+" = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
default:
System.out.println("First number must be from 1 to 5");
}
}
}
public class ConditionalSwitch {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
int a,b,c=1;
System.out.println("First number must be 1 to 5 and second from 1 to 100");
System.out.print("Enter first number = ");
a=in.nextInt();
System.out.print("Enter second number = ");
b=in.nextInt();
switch(a)
{
case 1:
if (b<100 && b>1)
{
c = a * b;
System.out.println("Product of both numbers = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
case 2:
if (b<100 && b>1)
{
c = a + b;
System.out.println("Sum of both numbers = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
case 3:
if (b<100 && b>1)
{
c = a - b;
System.out.println(""+a+" - "+b+" = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
case 4:
if (b<100 && b>1)
{
c = a / b;
System.out.println(""+a+" / "+b+" = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
case 5:
if (b<100 && b>1)
{
c = b % a;
System.out.println("Remainder of "+b+" / "+a+" = "+c);
}
else
System.out.println("Second number must be from 1 to 100");
break;
default:
System.out.println("First number must be from 1 to 5");
}
}
}
Create package store. Write a class name store in that package. Think of the attributes and methods should be for store as super class. Create a subclasses and store in packages for store such as music store, bike store and grocery store. Design any output that your think suitable for the classes. help me...
ReplyDeleteThank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging
ReplyDeleteDot Net Training in Chennai | Dot Net Training Center in Chennai | Dot Net Course in Chennai
Software Testing Training in Chennai | Best Software Testing Training Institute in Chennai | Testing Courses in Chennai
Java Training Institute in Chennai | Core Java Training in Chennai | Java Course and Certification
PHP Course in Chennai | PHP Training Institute in Chennai | PHP Course and Certification