Sample MIS 210 Assignment 2
Sample MIS 210 Assignment 2
Section – 01
Student Details
1511498030
Submitted To
Department of Management
CODE : Welcome to MIS
INPUT
publicclass welcome {
publicstaticvoid main(String args[])
{System.out.println("Welcome to MIS210");
}
}
OUTPUT
Console - Welcome to MIS210
OUTPUT
OUPUT
OUTPUT
Console: WELCOME TO
MIS210 class
Code: Subtract
Input:
import java.util.Scanner;
public class Multyply {
scan.close();
System.out.println("Output: "+product);
}
}
Output:
Input:
import java.util.Scanner;
import javax.swing.JOptionPane;
public class calculator3 {
if (operation == "+");
{
System.out.println("your answer is " + (num1 + num2));
}
if (operation == "-");
{
System.out.println("your answer is " + (num1 - num2));
}
if (operation == "/");
{
System.out.println("your answer is " + (num1 / num2));
}
if (operation == "*")
{
System.out.println("your answer is " + (num1 * num2));
}
Output:
CODE : Calculator
Input:
import javax.swing.JOptionPane;
public class calculator2 {
Output:
CODE : Calculator
INPUT
Import javax.swing.JOptionPane;
publicclass calculator {
JOptionPane.showMessageDialog(null,"Welcome to my Biodata");
String Firstname = JOptionPane.showInputDialog(null,"Enter your first
Name :");
}
}
Output
CODE: INPUT
INPUT
importjava.util.Scanner;
class input {
privatestatic Scanner input;
OUPUT
Console: Enter float; 15
Float entered = 15.0
Enter double; 20
Double entered = 20.0
Enter text;numbers are they key to success
Text entered = numbers
CODE: Sum of integer numbers
INPUT
importjava.util.Scanner;
publicclass NUMBER
{
privatestatic Scanner input;
publicstaticvoid main(String[]args) {
input = new Scanner(System.in);
intnumber1;
intnumber2;
intsum;
OUPUT
publicstaticvoid main(String[]args) {
input = new Scanner(System.in);
intnumber1;
intnumber2;
intsum;
System.out.print("Enter the first interger:");
number1=input.nextInt();
System.out.print("Enter the Second interger:");
number2=input.nextInt();
sum=number1-number2;
System.out.printf("Sum is: %d\n",sum);
}
}
OUTPUT
Enter the first interger:50
Enter the Second interger:40
Sum is: 10
CODE : Grocery
INPUT
importjava.util.Scanner;
publicclass grocery {
publicstaticvoid main(String args[])
{ Scannerinput = new Scanner (System.in);
floatx,y,z,a,b,c,t,r,m,n;
System.out.print("Enter Budget: ");
z = input.nextFloat();
System.out.print ("Enter price of rice per kg: ");
x = input.nextFloat();
System.out.print("Price purchase in kg:");
a = input.nextFloat();
System.out.print("Enter the price of milk per liter:");
y = input.nextFloat();
System.out.print("Milk purchase in liter:");
b = input.nextFloat();
m = x*a;
System.out.printf("Total price of rice:" + m);
n = y*b;
System.out.printf("\n Total price of milk:" + n);
t = m+n;
System.out.printf("\n Total spending:" + t);
r = z-t;
System.out.printf("\n Remaining Balance:" + r);
OUTPUT
Enter Budget: 5000
Enter price of rice per kg: 60
Price purchase in kg:5
Enter the price of milk per liter:80
Milk purchase in liter:2
Total price of rice:300.0
Total price of milk:160.0
Total spending:460.0
Remaining Balance:4540.0
CODE : Grocery
INPUT
import java.util.Scanner;
int choice = 1;
double subtotal = 0;
double price = 0;
double discount = 0;
System.out.println("Steve's Groceries");
System.out.println("\n");
System.out.println("");
System.out.println("0. Quit");
System.out.println("");
System.out.println("What would you like to purchase? \nIf you have completed your
checkout, enter 0.");
choice = input.nextInt();
if (choice == 0)
break;
switch (choice) {
case 1:
price = 1.99;
break;
case 2:
price = 2.19;
break;
case 3:
price = 0.99;
break;
case 4:
price = 3.49;
break;
case 5:
price = 0.88;
break;
case 6:
price = 1.29;
break;
case 7:
price = 1.59;
break;
case 8:
price = 7.99;
break;
case 9:
price = 4.99;
break;
case 10:
price = 2.49;
}
double tax = ((subtotal - discount) * 0.075);
OUTPUT
Steve's Groceries
0. Quit
Input:
import java.util.Scanner;
public class Groceries
System.out.print("Enter Budget:");
z=input.nextFloat();
System.out.print("Enter price of rice per kg:");
x=input.nextFloat();
System.out.print("Rice purchased in Kg:");
a=input.nextFloat();
System.out.print("Enter price of milk per ltr:");
y=input.nextFloat();
System.out.print("Milk purchased in ltr:");
b=input.nextFloat();
m=x*a;
System.out.printf("\n Total price of rice:" +m);
n=y*b;
System.out.printf("\n Total price of milk:" +n);
t=m+n;
System.out.printf("\n Total spending:" +t);
r=z-t;
System.out.printf("\n Remaining:" +r);
}
OUTPUT:
Enter Budget:2000
Enter price of rice per kg:50
Rice purchased in Kg:5
Enter price of milk per ltr:60
Milk purchased in ltr:2
System.out.print("Enter Budget:");
b=input.nextFloat();
System.out.print("Enter price of Oil per ltr:");
o=input.nextFloat();
System.out.print("Oil purchased in ltr:");
x=input.nextFloat();
System.out.print("Enter price of a Machine:");
m=input.nextFloat();
System.out.print("Amount of Machine purchased:");
y=input.nextFloat();
p=o*x;
System.out.printf("\n Total price of Oil:" +p);
q=m*y;
System.out.printf("\n Total price of Machine:" +q);
t=p+q;
System.out.printf("\n Total spending:" +t);
r=b-t;
System.out.printf("\n Remaining:" +r);
}
}
Output:
Enter Budget:20000
Enter price of Oil per ltr:100
Oil purchased in ltr:6
Enter price of a Machine:10000
Amount of Machine purchased:1
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 price of a Luggage:");
m=input.nextFloat();
System.out.print("Amount of Luggage purchased:");
y=input.nextFloat();
p=o*x;
System.out.printf("\n Total price of Air tickets:" +p);
q=m*y;
System.out.printf("\n Total price of Luggages:" +q);
t=p+q;
System.out.printf("\n Total spending:" +t);
r=b-t;
System.out.printf("\n Remaining:" +r);
}
}
Output:
Enter Budget:300000
Enter price of an Air ticket:52000
Amount of air ticket purchased:2
Enter price of a Luggage:2500
Amount of Luggage purchased:2
CODE: Math
INPUT
OUTPUT
30.09
CODE: Math
INPUT
package math;
publicclass floor {
publicstaticvoid main(String args[])
{System.out.println(Math.floor(25.5));
}
}
OUTPUT
25
CODE: Math
INPUT
publicclass ceil {
publicstaticvoid main(String args[])
{System.out.println(Math.ceil(25.5));
}
}
OUTPUT
25
INPUT
import javax.swing.JOptionPane;
publicclass box {
publicstaticvoid main(String args[]) {
String a,b,c;
intx,y,z;
a=JOptionPane.showInputDialog(null, "Enter base value;");
x= Integer.parseInt(a);
b= JOptionPane.showInputDialog(null,"Enter power");
y= Integer.parseInt(b);
JOptionPane.showMessageDialog(null,"Your answer is:"+Math.pow(x, y));
}
}
OUTPUT
CODE: Currency Exchange
INPUT
import java.util.Scanner;
publicclass Exchange_rate {
publicstaticvoid main(String args[])
{Scanner input= new Scanner(System.in);
doubletaka;
double doller =84.45;
double pound =105;
System.out.print("Enter taka:");
taka=input.nextDouble();
doubletotal=taka/doller;
System.out.println("Dollar converted:");
System.out.println(total);
doubletotal2=taka/pound;
System.out.println("pound converted:");
System.out.println(total2);
}
}
OUTPUT
Enter taka: 500
Dollar converted: 5.920663114268798
Pound converted: 4.761904761904762
INPUT:
import javax.swing.JOptionPane;
public class Pound_converter {
OUTPUT:
CODE: Currency Exchange adding floor ceil
INPUT
import java.util.Scanner;
System.out.print("Enter taka:");
taka=input.nextDouble();
double total=taka/doller;
System.out.println("Dollar converted:");
System.out.println(total);
doubletotal2=taka/pound;
System.out.println("pound converted:");
System.out.println(total2);
OUTPUT
Enter taka: 500
Dollar converted: 5.920663114268798
Pound converted: 4.761904761904762
Double round of floor: 5.0
Dollar round of ceiling: 6.0
Double round of floor: 4.0
Pound round of ceiling: 5.0
{double amount;
double rate=0.01;
{amount=principle*Math.pow(1+rate,day);
System.out.println(day+" "+amount);
OUTPUT
1 10100.0
2 10201.0
3 10303.010000000002
4 10406.0401
5 10510.100501
6 10615.201506010002
7 10721.353521070101
8 10828.567056280803
9 10936.852726843608
10 11046.221254112046
11 11156.683466653165
12 11268.250301319698
13 11380.932804332895
14 11494.742132376226
15 11609.689553699987
16 11725.786449236988
17 11843.044313729357
18 11961.47475686665
19 12081.089504435316
20 12201.900399479671
21 12323.919403474469
22 12447.158597509211
23 12571.630183484303
24 12697.346485319147
25 12824.319950172337
26 12952.563149674063
27 13082.088781170803
28 13212.909668982511
29 13345.038765672336
30 13478.489153329061
CODE : Loan Amortization
INPUT
Import java.text.DecimalFormat;
{doubleloan_Amount=500000;
doubleloan_year=5;
doubleloan_Balance=loan_Amount;
doublemonthly_interest;
doubleprinciles;
System.outprintln(“Monthly payment:$”+number.format(payment));
System.outprintln(“………………..”);
If(month!=number of payment);
{principle=payment-monthly_interest;)
Else,
{principle=loan_Balance;
Payment=loan_Balance+monthly_interest;}
Loan_Balance=principle;
System.out.println(month+”\t”+number.format(monthly_interest)
+”\t\t”+number.format(principle)
+”\t\t”+number.format(loan_Balance));
}}
OUTPUT
9
2
3
9
9
4
importjava.util.Random;
public class Random_number {
public static void main (String args[]) {
Random Random_number = new Random ();
intnumber;
for (intcounter = 1; counter<=100;counter++)
{number = 1+ Random_number.nextInt (8);
System.out.printf("%d", number);
if (counter % 4 == 0)
System.out.println();
}}}
OUTPUT
7117
6648
8485
3175
8685
7817
6165
3676
3822
1276
7224
4267
8531
1573
8236
4342
7173
2871
7534
7746
8362
3167
6373
6165
1721
importjava.util.Random;
publicclassRandom_number {
publicstaticvoid main (String args[]) {
System.out.println("Telephone number for Gulshan");
System.out.println();
Random Random_number = newRandom();
intGulshan;
for (intcounter = 1; counter<100; counter++)
{Gulshan = 80+ Random_number.nextInt(8);
System.out.printf("%d", Gulshan);
if (counter %6 == 0)
System.out.println();
}}}
OUTPUT
Telephone number for Gulshan
848086828081
838282808581
868384868484
838484838180
808583838486
868484818085
828281838185
828385838585
818387838287
808680868385
858787848386
838183838485
858187818683
848687868782
838180818187
858681878180
878285
CODE: Temperature
INPUT
import javax.swing.*;
else
{JOptionPane.showMessageDialog(null, "you are fine");}
}
}
OUTPUT
CODE: Temperature
INPUT
import javax.swing.*;
else
{JOptionPane.showMessageDialog(null, "you are fine");}
}
}
Output
Code: Grade
INPUT
import java.util.Scanner;
String msg;
if (grade >= 90) {
msg = "A";
} else if (grade >= 80) {
msg = "B";
} else if (grade >= 70) {
msg = "C";
} else if (grade >= 60) {
msg = "D";
} else if (grade >= 50) {
msg = "E";
} else {
msg = "F";
}
System.out.println("Your grade is: " + msg);
}
}
OUTPUT
Code: Grading
INPUT
import java.util.Scanner;
String msg;
if (grade >= 90) {
msg = "A";
} else {
msg = "F";
}
System.out.println("Your grade is: " + msg);
}
}
OUTPUT
Code : Math
Input:
import javax.swing.JOptionPane;
public class math {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, Math.pow(66,2));
}
Output:
Code : Supplies
INPUT:
import javax.swing.JOptionPane;
public class Supllies {
if(pen<20||pencil<10)
{JOptionPane.showMessageDialog(null, "X should buy pen");}
else
{JOptionPane.showMessageDialog(null, "X should buy pencil");}
}
}
OUTPUT:
CODE : JOB
Input:
import javax.swing.JOptionPane;
public class job {
public static void main(String args[])
{String a,b;
int female;
int male;
a=JOptionPane.showInputDialog("Enter female age:");
female=Integer.parseInt(a);
else
{JOptionPane.showMessageDialog(null, "You cannot apply");}
}
}
OUTPUT
CODE : Purchase
Input:
import javax.swing.JOptionPane;
public class Purchase
{public static void main (String args[])
{String h,m,n,o,x,y,z,M,D,C,I,U,N,A;
int a,b,c,p,q,r,u,v,w,s,d,e,i,j,k,f,t,g,l,S,R,K,O,F,P,G,V,Q,J,E,Z;
h=JOptionPane.showInputDialog("Enter Budget ");
a=Integer.parseInt(h);
}
}
Output
CODE: Interest
INPUT:
import javax.swing.JOptionPane;
public class DBBL {
}
}
} OUTPUT:
Code: Car loan
Input: public class Car_loan {
Output:
2227
Code: Password
Input:
import java.util.Scanner;
public class password_open {
public static void main (String args[]) {
System.out.println("please guess the password:") ;
}
}
}
}
Output:
import java.util.Random;
public class Random_Number {
public static void main (String args[]) {
Random dice = new Random() ;
int number;
for (int counter = 1; counter<10; counter++) {
number = 1+dice.nextInt(6);
System.out.println(number);
}
}
}
Output:
4
5
5
2
5
3
1
6
4
Code: Work
Input:
package assignment;
import javax.swing.JOptionPane;
Output:
Code: Interest
Input :
import javax.swing.JOptionPane;
public class taka {
public static void main(String args[]) {
String s = JOptionPane.showInputDialog ("enter the capital");
double capital = Double.parseDouble (s);
double principle = 10000;
double rate = .01;
for (int day = 1; day <=20;day++) {
capital = principle*Math.pow (1+rate,day);
System.out.println(day+" "+capital);
}
}
}
Output:
1 10100.0
2 10201.0
3 10303.010000000002
4 10406.0401
5 10510.100501
6 10615.201506010002
7 10721.353521070101
8 10828.567056280803
9 10936.852726843608
10 11046.221254112046
11 11156.683466653165
12 11268.250301319698
13 11380.932804332895
14 11494.742132376226
15 11609.689553699987
16 11725.786449236988
17 11843.044313729357
18 11961.47475686665
19 12081.089504435316
20 12201.900399479671
Code: JOB
Input:
import javax.swing.JOptionPane;
public class business {
Output:
CODE : Challenge
Input:
package assignment;
import javax.swing.JOptionPane;
OUTPUT:
CODE: Buying
Input:
import javax.swing.JOptionPane;
public class instruments {
public static void main (String args[]){
String c,d;
float q, r ,s;
c = JOptionPane.showInputDialog (null, "Enter companey of products
price:","PRODUCTS", JOptionPane.PLAIN_MESSAGE);
q = Integer.parseInt(c);
d = JOptionPane.showInputDialog (null, "Enter products price:","PRICE",
JOptionPane.PLAIN_MESSAGE);
r = Integer.parseInt(c);
s = q/r;
JOptionPane.showMessageDialog (null, "TAKA converted:"+s,"CONVERTED
TAKA",JOptionPane.PLAIN_MESSAGE);
}
}
Output: