You are on page 1of 27

Q6:

Input:
Output:

Welcome

Q1:

Input:

public class Welcome


{public static void main(String args[])
{System.out.println("Welcome to Java");
}}
Output:

Q2:

Input:

public class Welcome


{public static void main(String args[])
{System.out.println("Welcome to MIS210");
}}
Output:

Q3:

Input:
public class Welcome2
{public static void main(String args[])
{System.out.println("Welcome to Bangladesh \nHope you have an amazing
vacation ");
}}
Output:

Q4:

Input:

import javax.swing.JOptionPane ;
public class Welcome
{public static void main (String args [])
{JOptionPane.showMessageDialog(null,"Welcome to MIS Department”);
}}
Output:

Q5:

Input:

import javax.swing.JOptionPane ;
public class WelcomeBox
{public static void main (String args [])
{JOptionPane.showMessageDialog(null, "Welcome to Dhaka \nThe capital
of Bangladesh”);
}}
Output:
Message
Q1:

Input:

import java.util.Scanner;
publicclass Message
{publicstaticvoid main (String args [])
{Scanner input = new Scanner (System.in);
System.out.print("First Name:");
String firstname = input.nextLine();
System.out.print("Last Name:");
String lastname = input.nextLine();
String message = String.format("Best of luck %s
%s",firstname,lastname);
System.out.print(message);
}}
Output:

Q2:

Input:

import javax.swing.JOptionPane;
public class MessageBox
{public static void main (String args [])
{String firstname = JOptionPane.showInputDialog("Enter First
Name:");
String lastname = JOptionPane.showInputDialog("Enter Last
Name:");
String message = String.format("Best of luck %s %s", firstname,
lastname);
JOptionPane.showMessageDialog(null, message);
}}
Output:

Q3:

Input:

import javax.swing.JOptionPane;
public class MessageBox 
{public static void main(String args[])
{String firstname=JOptionPane.showInputDialog(null,"Enter first
name:");
String lastname=JOptionPane.showInputDialog(null,"Enter last name:");
String Message=String.format("Welcome to MIS class Mr. %S
%S",firstname,lastname);
JOptionPane.showMessageDialog(null,Message);
}}
Output:
Q4:

Input:

import java.util.Scanner;
public class Message
{public static void main (String args[])
{Scanner Input = new Scanner(System.in);
System.out.print("Please Enter Your Full Name: ");
String fullname = Input.nextLine();
System.out.print("Please Enter Your Age: ");
String age = Input.nextLine();
String message = String.format("Best of luck %S %s", fullname,age);
System.out.print(message);
}}
Output:

Q5:

Input:

import javax.swing.JOptionPane;
public class MessageBox 
{public static void main(String args[])
{String fullname=JOptionPane.showInputDialog(null," Please Enter Your
Full Name:");
String age=JOptionPane.showInputDialog(null," Please Enter Your
Age:");
String Message=String.format("Best of luck %S %s",fullname,age);
JOptionPane.showMessageDialog(null,Message);
}}
Output:
Q6:

Input:

import java.util.Scanner;
public class MessageNameAgeSalary 
{public static void main(String args[])
{Scanner input=new Scanner(System.in);
System.out.println("Enter name,age & salary:");
String name=input.nextLine();
int age=input.nextInt();
double salary=input.nextDouble();
System.out.println("Name:"+name);
System.out.println("Age:"+age);
System.out.println("Salary:"+salary);
}}
Output:

Q7:

Input:

import javax.swing.JOptionPane;
public class welcome3
{public static void main (String args[])
{String name = JOptionPane.showInputDialog (null, "What is your
name?");
{String country = JOptionPane.showInputDialog (null, "Which country
are you from?");
String message = String.format ("Welcome %S %S", name," from
"+country);
JOptionPane.showMessageDialog (null, message);
}}}
Output:
Calculation

Q1:
Input:

import java.util.Scanner;
public class NUMBER-Addition  
{public static void main (String args [])
{Scanner input = new Scanner (System.in);
System.out.print("Enter first integer:");
int number1 = input.nextInt ();
System.out.print("Enter second integer:");
int number2 = input.nextInt ();
int sum = number1+number2;
System.out.printf("Sum is %d",sum);
}}

Output:

Q2:
Input:
import java.util.Scanner;
public class NUMBER
{public static void main(String args[])
{Scanner input=new Scanner(System.in);
int a,b,c,sum;
System.out.print("Enter A:");
a=input.nextInt();
System.out.print("Enter B:");
b=input.nextInt();
System.out.print("Enter C:");
c=input.nextInt();
sum=(a*b*c*(b-a));
System.out.printf("Total is %d",sum);
}}

Output:
Q3:
Input:

import javax.swing.JOptionPane;
public class NumberBOX 
{public static void main(String args[])
{String p,q,r;
double a,b,c,total;
p=JOptionPane.showInputDialog(null,"Enter A:");
a=Integer.parseInt(p);
q=JOptionPane.showInputDialog(null,"Enter B:");
b=Integer.parseInt(q);
r=JOptionPane.showInputDialog(null,"Enter C:");
c=Integer.parseInt(r);
total=a*(b-c);
JOptionPane.showMessageDialog(null,"total is\n"+total);
}}
Output:
Q4:
Input:
import java.util.Scanner;
public class NUMBER-Subtraction 
{public static void main (String args [])
{Scanner input = new Scanner (System.in);
System.out.print("Enter first integer:");
int number1 = input.nextInt ();
System.out.print("Enter second integer:");
int number2 = input.nextInt ();
int sum = number1-number2;
System.out.printf("Sum is %d",sum);
}}

Output:

Q5:

Input:

import java.util.Scanner;
public class Number-Calculation
{public static void main (String args[])
{Scanner input = new Scanner(System.in);
int a,b,c,d,sum;

System.out.print("Enter A: ");
a = input.nextInt ();

System.out.print("Enter B: ");
b = input.nextInt ();

System.out.print("Enter C: ");
c = input.nextInt ();
System.out.print("Enter D: ");
d = input.nextInt ();

sum = (a*b)+(c-d);
System.out.printf("\nSum is: %d", sum);
sum = ((a+b)-c);

System.out.printf("\nSum is: %d", sum);


sum = ((a+b+c)-d);
System.out.printf("\nSum is: %d", sum);
}}

Output:

Grocery,Factory,Shopping,Vacation

Q1:

Input:

import java.util.Scanner;
public class Grocery 
{public static void main(String args[])
{Scanner input=new Scanner(System.in);
float a,b,m,n,x,y,z,t,r;
System.out.print("Enter Budget:");
z=input.nextFloat();
System.out.print("Enter price of Rice per kg:");
x=input.nextFloat();
System.out.print("Rice purchase in kg:");
a=input.nextFloat();
System.out.print("Enter price of milk per liter:");
y=input.nextFloat();
System.out.print("MIlk purchased in liter");
b=input.nextFloat();
m=x*a;
System.out.printf("Total price of rice:"+m);
n=y*b;
System.out.printf("\nTotal price of milk:"+n);
t=m+n;
System.out.printf("\nTotal spending:"+t);
r=z-t;
System.out.printf("\nRemaining:"+r);
}}
Output:

Q2:

Input:

import javax.swing.JOptionPane;
public class GroceryBOX 
{public static void main(String args[])
{String c,d,e,f,g;
double a,b,m,n,x,y,z,t,r;
c=JOptionPane.showInputDialog(null,"Enter Budget:");
z=Integer.parseInt(c);
d=JOptionPane.showInputDialog(null,"Enter price of Rice per kg:");
x=Integer.parseInt(d);
e=JOptionPane.showInputDialog(null,"Rice purchase in kg:");
a=Integer.parseInt(e);
m=x*a;
JOptionPane.showMessageDialog(null,"Total price of rice:"+m);
f=JOptionPane.showInputDialog(null,"Enter price of milk per
liter:");
y=Integer.parseInt(f);
g=JOptionPane.showInputDialog(null,"MIlk purchased in liter:");
b=Integer.parseInt(g);
n=y*b;
JOptionPane.showMessageDialog(null,"Total price of milk:"+n);
t=m+n;
JOptionPane.showMessageDialog(null,"Total spending:"+t);
r=z-t;
JOptionPane.showMessageDialog(null,"Remaining:"+r);
}}

Output:
Q3:

Input:

import java.util.Scanner;
public class Factory
{public static void main( String args[])
{Scanner input= new Scanner ( System.in);
Float a,b,c,d,p,r;
System.out.print("Cost of raw material for one shirt:");
a=input.nextFloat();
System.out.print("Labour cost for one shirt:");
b=input.nextFloat();
System.out.print("Overhead expense for one shirt:");
c=input.nextFloat();
System.out.print("Amount of shirt produced:");
d=input.nextFloat();
p=a+b+c;
System.out.printf("\n Total cost of one shirt:" +p);
r=d*p;
System.out.printf("\n Total cost of shirt produced:" +r);
}}

Output:
Q4:

Input:

Import java.util.Scanner;
public class Vacation
{public static void main(String args[])
{Scanner input= new Scanner(System.in);
Float c,b,o,x,m,a,y,p,q,t,r;
System.out.print("Enter Budget:");
b=input.nextFloat();
System.out.print("Enter price of an Air ticket:");
o=input.nextFloat();
System.out.print("Amount of air ticket purchased:");
x=input.nextFloat();
System.out.print("Enter cost of hotel per day:");
m=input.nextFloat();
System.out.print("Enter cost of food per day:");
a=input.nextFloat();
System.out.print("Number of days stay:");
y=input.nextFloat();
p=o*x;
System.out.printf("\n Total price of Air tickets:" +p);
q=m*y;
System.out.printf("\n Total cost of hotel:" +q);
c=a*y;
System.out.printf("\n Total cost of food:" +c);
t=p+q+c;
System.out.printf("\n Total spending:" +t);
r=b-t;
System.out.printf("\n Remaining:" +r);
}}
Output:

Q5:

Input:

import java.util.Scanner;
public class Shopping
{public static void main(String args[])
{Scanner input = new Scanner(System.in);
Float a,b,c,d,e,x,y,z;
System.out.print("Budget:");
z = input.nextFloat();
System.out.print("Price of the Panjabi:");
a = input.nextFloat();
System.out.print("Price of the Pajama:");
b = input.nextFloat();
System.out.print("Price of the Shirt:");
c = input.nextFloat();
System.out.print("Price of the Pant:");
d = input.nextFloat();
System.out.print("Price of Shoe:");
e = input.nextFloat();
x = a+b+c+d+e;
System.out.printf("\n Total Cost:"+x);
y = z-x;
System.out.printf("\n Remaining Cash:"+y);
}}

Output:
If-Else

Q1:

Input:

import javax.swing.JOptionPane;
public class AGE
{public static void main(String args[])
{String a,b;
int Rafi;
int Shahriar;
a=JOptionPane.showInputDialog("Enter Age of Rafi:");
Rafi=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Enter Age of Shahriar:");
Shahriar=Integer.parseInt(b);
if (Rafi>=22 && Shahriar<22)
{JOptionPane.showMessageDialog(null,"Rafi is older");}
else
{JOptionPane.showMessageDialog(null,"Shahriar is older");}
}}

Output:
Q2:
Input:

import javax.swing.JOptionPane;
public class Price
{public static void main(String args[])
{String a,b;
int Pasta;
int Steak;
a=JOptionPane.showInputDialog("Enter Pasta price:");
Pasta=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Enter Steak price:");
Steak=Integer.parseInt(b);
if (Pasta<400 || Steak<1200)
{JOptionPane.showMessageDialog(null,"We should have Pasta");}
else
{JOptionPane.showMessageDialog(null,"We should have Steak");}
}}

Output:

Q3:
Input:

import javax.swing.JOptionPane;
public class Salary
{public static void main(String args[])
{String a,b;
int Rafi;
int Shahriar;
a=JOptionPane.showInputDialog("Experiance of Rafi:");
Rafi=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Experiance of Shahriar:");
Shahriar=Integer.parseInt(b);
if (Rafi>=8 || Shahriar<8)
{JOptionPane.showMessageDialog(null,"Rafi will get better salary then
Shahriar");}
else
{JOptionPane.showMessageDialog(null,"Shahriar will get better salary
then Rafi");}
}}

Output:

Q4:
Input:

import javax.swing.JOptionPane;
public class Vote
{public static void main(String args[])
{String a,b;
int x;
int y;
a=JOptionPane.showInputDialog("Enter total of candidate A:");
x=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Enter total of candidate B:");
y=Integer.parseInt(b);
if (x>=200000 || y<200000)
{JOptionPane.showMessageDialog(null,"Candidate A is Winnner");}
else
{JOptionPane.showMessageDialog(null,"Candidate B is Winnner");}
}}
Output:

Q5:
Input:

import javax.swing.JOptionPane;
public class Choice
{public static void main(String args[])
{String a,b;
int Prius;
int Aqua;
a=JOptionPane.showInputDialog("Enter price of Toyota Prius:");
Prius=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Enter price of Toyota Aqua:");
Aqua=Integer.parseInt(b);
if (Prius<=1800000 && Aqua<=1350000)
{JOptionPane.showMessageDialog(null,"I will buy Toyota Prius");}
else
{JOptionPane.showMessageDialog(null,"I will buy Toyota Aqua");}
}}

Output:
Q6:
Input:

import javax.swing.JOptionPane;
public class Purchase
{public static void main(String args[])
{String a,b;
int pen;
int pencil;
a=JOptionPane.showInputDialog("Enter price pen:");
pen=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Enter price pencil:");
pencil=Integer.parseInt(b);
if (pen<=10 && pencil>=5)
{JOptionPane.showMessageDialog(null,"I will buy pen");}
else
{JOptionPane.showMessageDialog(null,"I will buy pencil");}
}}
Output:
Q7:
Input:

import javax.swing.JOptionPane;
public class Like
{public static void main(String args[])
{String a,b;
int Madchef;
int Takeout;
a=JOptionPane.showInputDialog("Madchef's total page like:");
Madchef=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Takeout's total page like:");
Takeout=Integer.parseInt(b);
if (Madchef>=20000 || Takeout<20000)
{JOptionPane.showMessageDialog(null,"Madchef is more popular");}
else
{JOptionPane.showMessageDialog(null,"Takeout is more popular");}
}}

Output:
Q8:
Input:

import javax.swing.JOptionPane;
public class Rent
{public static void main(String args[])
{String a,b;
int Gulshan;
int Dhanmondi;
a=JOptionPane.showInputDialog("Gulshan flat rent:");
Gulshan=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Dhanmondi flat rent:");
Dhanmondi=Integer.parseInt(b);
if (Gulshan<=50000 || Dhanmondi>50000)
{JOptionPane.showMessageDialog(null,"We will stay at Gulshan");}
else
{JOptionPane.showMessageDialog(null,"We will stay at Dhanmondi");}
}}

Output:

Q9:
Input:

import javax.swing.JOptionPane;
public class Admission
{public static void main(String args[])
{String a,b;
int Burger;
int Pizza;
a=JOptionPane.showInputDialog("Enter mark of Rafi:");
Burger=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Enter mark of Shahriar:");
Pizza=Integer.parseInt(b);
if (Burger>=85 && Pizza<85)
{JOptionPane.showMessageDialog(null,"Rafi is selected");}
else
{JOptionPane.showMessageDialog(null,"Shahriar is selected");}
}}
Output:

Q10:
Input:

import javax.swing.JOptionPane;
public class Vacation
{public static void main(String args[])
{String a,b;
int india;
int thailand;
a=JOptionPane.showInputDialog("India vacation cost per person:");
india=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Thailand vacation cost per person:");
thailand=Integer.parseInt(b);
if (india<=10000 && thailand>10000)
{JOptionPane.showMessageDialog(null,"We will go India");}
else
{JOptionPane.showMessageDialog(null,"We will go Thailand");}
}}

Output:

You might also like