0% found this document useful (0 votes)
135 views55 pages

Sample MIS 210 Assignment 2

The document contains Java code snippets submitted by a student for their MIS 210 class assignment. The codes demonstrate basics of Java programming including input/output, variables, data types, operators, conditional statements, and functions. The codes cover topics like welcoming messages, calculations, taking user input, and a grocery shopping program. The student has provided the code, input, and output for each program.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views55 pages

Sample MIS 210 Assignment 2

The document contains Java code snippets submitted by a student for their MIS 210 class assignment. The codes demonstrate basics of Java programming including input/output, variables, data types, operators, conditional statements, and functions. The codes cover topics like welcoming messages, calculations, taking user input, and a grocery shopping program. The student has provided the code, input, and output for each program.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 55

MIS 210

Section – 01

Assignment – Typed codes for java programming

Student Details

MD. Tohedul Islam

1511498030

Submitted To

Mohammad Rashed Uzzaman (RZZ)

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

CODE : Welcome to MIS210


INPUT
publicclass welcome {
publicstaticvoid main(String args[])
{System.out.println("Welcome to MIS210\n class");
}
}

OUTPUT

Console - Welcome to MIS210


class
CODE : Welcome to MIS210
INPUT
importjavax.swing.JOptionPane;
publicclass welcome {
publicstaticvoid main(String args[])
{JOptionPane.showMessageDialog(null,"Welcome to MIS210\n class");
}
}

OUPUT

CODE : Welcome To Mis210


INPUT
publicclass welcome
{
publicstaticvoid main (String args[])
{
System.out.printf("%S\n %s\n","Welcome to","MIS210 class");
}
}

OUTPUT

Console: WELCOME TO
MIS210 class
Code: Subtract

Input:
import java.util.Scanner;
public class Multyply {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);


System.out.print("Enter first number: ");

int num1 = scan.nextInt();

System.out.print("Enter second number: ");


int num2 = scan.nextInt();

scan.close();

int product = num1*num2;

System.out.println("Output: "+product);
}
}

Output:

Enter first number: 55


Enter second number: 2
Output: 110
Code: calculator

Input:

import java.util.Scanner;
import javax.swing.JOptionPane;
public class calculator3 {

public static void main(String[] args){


{
int num1;
int num2;
String operation;

Scanner input = new Scanner(System.in);

System.out.println("please enter the first number");


num1 = input.nextInt();

System.out.println("please enter the second number");


num2 = input.nextInt();

Scanner op = new Scanner(System.in);

System.out.println("Please enter operation");


operation = op.next();

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 {

public static void main(String args[])


{double answer ;

JOptionPane.showMessageDialog(null, "Wellcome to my calculator");

String read = JOptionPane.showInputDialog("enter your frist number:");


double fnam= Double.parseDouble(read);

String read1 = JOptionPane.showInputDialog("enter your sceond number");


double snam= Double.parseDouble(read1);
answer=fnam*snam;
JOptionPane.showMessageDialog(null, answer);

Output:
CODE : Calculator
INPUT
Import javax.swing.JOptionPane;
publicclass calculator {

publicstaticvoid main(String args[])


{doubleanswer;
JOptionPane.showMessageDialog(null,"Welcome to my Calculator");
String read = JOptionPane.showInputDialog("Enter your first number:");
doublefnum=Double.parseDouble(read);
String read1 = JOptionPane.showInputDialog("Enter your second number:");
doublesnum=Double.parseDouble(read1);
String read2 = JOptionPane.showInputDialog("Enter your third number:");
doubletnum=Double.parseDouble(read2);
String read3 = JOptionPane.showInputDialog("Enter your fourth number:");
doublefornum=Double.parseDouble(read3);
answer=fnum+snum*tnum/fornum;
JOptionPane.showMessageDialog(null, answer);
}
}

CODE : Welcome to My Bio data


Input
importjavax.swing.JOptionPane;
publicclass Name {
public static void main(String args[]) {

JOptionPane.showMessageDialog(null,"Welcome to my Biodata");
String Firstname = JOptionPane.showInputDialog(null,"Enter your first
Name :");

String Lastname = JOptionPane.showInputDialog(null,"Enter your second


Name :");
String Subject = JOptionPane.showInputDialog(null,"Enter your
Subject :");
String Message = String.format("Welcome to %S class",Subject);
String message1 = String.format("Best of luck\n %S",
Firstname+Lastname);
JOptionPane.showMessageDialog(null,Message);
JOptionPane.showMessageDialog(null, message1);

}
}

Output
CODE: INPUT

INPUT

importjava.util.Scanner;
class input {
privatestatic Scanner input;

publicstaticvoid main(String[] args)


{
input = new Scanner(System.in);
System.out.print("Enter float; ");
floatmyFloat = input.nextFloat();
System.out.println("Float entered = " + myFloat);

System.out.print("Enter double; ");


doublemyDouble = input.nextDouble();

System.out.println("Double entered = " + myDouble);


System.out.print("Enter text;");

String myString = input.next();


System.out.println("Text entered = " + myString);
}
}

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;

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);
}
}

OUPUT

Console: Enter the first interger:10


Enter the Second interger:20
Sum is: 30
CODE: Subtraction
importjava.util.Scanner;
publicclass NUMBER
{
privatestatic Scanner input;

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;

public class groceryshopping{

public static void main(String args[]){

Scanner input = new Scanner(System.in);

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("1. Apples $ 1.99 per lbs");

System.out.println("2. Oranges $ 2.19 per lbs");

System.out.println("3. Chocolate Bar $ 0.99 each");

System.out.println("4. Ice Cream $ 3.49 a carton");

System.out.println("5. Watermelon $ 0.88 per lbs");

System.out.println("6. Cottage Cheese $ 1.29 package");

System.out.println("7. Mushrooms $ 1.59 per lbs");

System.out.println("8. NY Strip Steak $ 7.99 per lbs");

System.out.println("9. Pizza $ 4.99 each");

System.out.println("10. Strawberries $ 2.49 each");

System.out.println("");

System.out.println("0. Quit");

System.out.println("");

System.out.println("Your subtotal is $ " +(int)(subtotal * 100) / 100.0);

System.out.println("What would you like to purchase? \nIf you have completed your
checkout, enter 0.");

choice = input.nextInt();

if (choice == 0)

break;

System.out.println("How many do you want?");

int qty = input.nextInt();

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;

subtotal = subtotal + (qty * price);

while(choice > 0);

System.out.println("Are you a member of the A+ discount club? (Y/N)");

String discountInput = input.next();

char discountClub = discountInput.charAt(0);

if (discountClub == 'y' || discountClub == 'Y'){

discount = subtotal * .20;

}
double tax = ((subtotal - discount) * 0.075);

double finalCost = subtotal - discount + tax;

System.out.println("The subtotal is $ " + (int)(subtotal * 100) / 100.0);

System.out.println("A+ Member's Discount $ " + (int) (discount * 100) / 100.0);

System.out.println("Sales Tax $ " + (int)(tax* 100) / 100.0);

System.out.println("Final price $ " + (int)(finalCost * 100) / 100.0);

OUTPUT
Steve's Groceries

1. Apples $ 1.99 per lbs


2. Oranges $ 2.19 per lbs
3. Chocolate Bar $ 0.99 each
4. Ice Cream $ 3.49 a carton
5. Watermelon $ 0.88 per lbs
6. Cottage Cheese $ 1.29 package
7. Mushrooms $ 1.59 per lbs
8. NY Strip Steak $ 7.99 per lbs
9. Pizza $ 4.99 each
10. Strawberries $ 2.49 each

0. Quit

Your subtotal is $ 0.0


What would you like to purchase?
If you have completed your checkout, enter 0
Code: Grocery:

Input:
import java.util.Scanner;
public class Groceries

{public static void main( String args[])

{Scanner input= new Scanner ( System.in);


float x,y,a,b,z,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("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

Total price of rice:250.0


Total price of milk:120.0
Total spending:370.0
Remaining:1630.0
Code: Facory
Input:
package assignment;
import java.util.Scanner;
public class Factory {

public static void main( String args[])

{Scanner input= new Scanner ( System.in);


float b,o,x,m,y,p,q,t,r;

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

Total price of Oil:600.0


Total price of Machine:10000.0
Total spending:10600.0
Remaining:9400.0
Code : vacation
INPUT:
import java.util.Scanner;

public class Vacation


{public static void main( String args[])

{Scanner input= new Scanner ( System.in);


float b,o,x,m,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 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

Total price of Air tickets:104000.0


Total price of Luggages:5000.0
Total spending:109000.0
Remaining:191000.0

CODE: Math
INPUT

Public class MinMax {


Public stati cvoid main(String args[])
{doublea;
a = -30.09 ;
System.out.println(Math.abs(a));
}

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

CODE: Math Dialog Box

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

CODE: Currency Exchange adding floor ceil

INPUT:
import javax.swing.JOptionPane;
public class Pound_converter {

public static void main (String args[])


{String a,c;
double taka;
double pound = 110;
a=JOptionPane.showInputDialog("Enter taka Amount:");
taka=Double.parseDouble(a);
double total=taka/pound;
c=String.format("Pound converted:"+total+"\nPound roud of ceiling:
%2f",Math .ceil(total));
JOptionPane.showMessageDialog(null,c,"Pound
Converted",JOptionPane.PLAIN_MESSAGE);

OUTPUT:
CODE: Currency Exchange adding floor ceil
INPUT
import java.util.Scanner;

public class Exchange_rate {


public static void main(String args[])
{Scanner input= new Scanner(System.in);
Double taka;
Double doller =84.45;
Double pound =105;

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);

System.out.println("Double round of floor");


System.out.println(Math.floor(total));
System.out.println("Dollar round of ceiling:");
System.out.println(Math.ceil(total));

System.out.println("Double round of floor");


System.out.println(Math.floor(total2));
System.out.println("Pound round of ceiling:");
System.out.println(Math.ceil(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

CODE: Interest rate


INPUT

public class Dbbl {

public static void main (String args[])

{double amount;

double principle =10000;

double rate=0.01;

for (int day=1; day<=30; day++)

{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;

Public class Amortization

{public static void main(String args[])

{doubleloan_Amount=500000;

double interest Rate=0.20;

doubleloan_year=5;

doubleloan_Balance=loan_Amount;

double term=Math.pow(1+interest_Rate/12.0*loan year);

double payment=(loan Amount*interest_rate/12.0*term/term-1);

double number of Payment=loan_year*5;

doublemonthly_interest;

doubleprinciles;

DecimalFormat number= new Decimal Format(“#,##0.00”);

System.outprintln(“Monthly payment:$”+number.format(payment));

System.outprintln(“………………..”);

For(int month=1; month<=number of payment;month++);

{monthly interest=interest_rate/12.0*loan balance;

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));

}}

CODE: Random number


INPUT
Importjava.util.Random;
Public classRandom_number {
Public static void main (String args[]) {
Random Random_number = new Random ();
intnumber;
for (intcounter = 1; counter<8;counter++)
{number = 1+ Random_number.nextInt (9);
System.out.println(number + "");
}}}

OUTPUT
9
2
3
9
9
4

CODE: Random Number


INPUT

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

CODE: Random Telephone Number


INPUT

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.*;

public class Thermometer {


public static void main(String args[]){
Double temp = 100.3;

if (temp <= 93.5)

{JOptionPane.showMessageDialog(null,"you are sick");}

else
{JOptionPane.showMessageDialog(null, "you are fine");}
}
}

OUTPUT

CODE: Temperature
INPUT
import javax.swing.*;

public class Thermometer {


public static void main(String args[]){
Double temp = 100.3;

if (temp >= 93.5)

{JOptionPane.showMessageDialog(null,"you are sick");}

else
{JOptionPane.showMessageDialog(null, "you are fine");}
}
}

Output
Code: Grade
INPUT
import java.util.Scanner;

public class grade {


public static void main(String args[]) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter subject number: ");
Float grade = reader.nextFloat();

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;

public class grade {


public static void main(String args[]) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter subject number: ");
Float grade = reader.nextFloat();

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 : 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 {

public static void main(String args[])


{String a,b;
int pen;
int pencil;
a=JOptionPane.showInputDialog("Enter pen price:");
pen=Integer.parseInt(a);

b=JOptionPane.showInputDialog("Enter pencil price:");


pencil=Integer.parseInt(b);

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);

b=JOptionPane.showInputDialog("Enter male age :");


male=Integer.parseInt(b);

if(female > 18 && male > 20)


{JOptionPane.showMessageDialog(null, "You can apply");}

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);

m=JOptionPane.showInputDialog("Enter price of Betal leaf /pc ");


b=Integer.parseInt(m);
x=JOptionPane.showInputDialog("Betal leaf purchased");
i=Integer.parseInt(x);
e=b*i;
JOptionPane.showMessageDialog(null, "Total price of Betal leaf
purchased:"
+e, "Betal leaf",JOptionPane.PLAIN_MESSAGE);

n=JOptionPane.showInputDialog("Enter price of mint /pc bought");


c=Integer.parseInt(n);
y=JOptionPane.showInputDialog("Mints purchased");
j=Integer.parseInt(y);
f=c*j;
JOptionPane.showMessageDialog(null, "Total price of Mints purchased"
+f, "Mints",JOptionPane.PLAIN_MESSAGE);

o=JOptionPane.showInputDialog("Enter price of Softdrinks per 500ml


bottle ");
d=Integer.parseInt(o);
z=JOptionPane.showInputDialog("Softdrinks purchased ");
k=Integer.parseInt(z);
g=d*k;
JOptionPane.showMessageDialog(null, "Total price of softdrinks
purchased"
+g, "Softdrinks",JOptionPane.PLAIN_MESSAGE);

JOptionPane.showMessageDialog(null, "Total budget: "


+a, "Budget",JOptionPane.PLAIN_MESSAGE);
l=e+f+g;
JOptionPane.showMessageDialog(null, "Total Spent:"
+l, "Spent",JOptionPane.PLAIN_MESSAGE);
S=a-l;
JOptionPane.showMessageDialog(null, "Total Remaining:"
+S, "Remaining",JOptionPane.PLAIN_MESSAGE);

String print="Your Total budget"+a+"\n Price of Betal leaf:"+e+"\n Price


of Mints"+f+"\n Price of Softdrinks"+g+"\n Total spent"+l+"\n Total
Remaining"+S;
{JOptionPane.showMessageDialog(null,print);}
String message=String.format("TotalBudget:"+a+"\n Total spent: "+l+"\n
Total Remaining:"+S);
JOptionPane.showMessageDialog(null,message);

M=JOptionPane.showInputDialog("Enter price of Betal leaf /pc sold :");


K=Integer.parseInt(M);
N=JOptionPane.showInputDialog("Betal leaf sold: ");
O=Integer.parseInt(N);
V=K*O;
JOptionPane.showMessageDialog(null, "Total price of Betal leaf sold:"
+V, "Betal leaf",JOptionPane.PLAIN_MESSAGE);

C=JOptionPane.showInputDialog("Enter Selling price of a mint:");


F=Integer.parseInt(C);
D=JOptionPane.showInputDialog("Mints sold: ");
P=Integer.parseInt(D);
G=F*P;
JOptionPane.showMessageDialog(null, "Total price of mints sold:"
+G, "Mints",JOptionPane.PLAIN_MESSAGE);

I=JOptionPane.showInputDialog("Enter Selling price of Softdrinks: ");


Q=Integer.parseInt(I);
U=JOptionPane.showInputDialog("Soft drinks sold: ");
J=Integer.parseInt(U);
E=Q*J;
JOptionPane.showMessageDialog(null, "Total price of softdrinks sold:"
+E, "Softdrinks",JOptionPane.PLAIN_MESSAGE);

JOptionPane.showMessageDialog(null, "Total Spent: "


+l, "Spent",JOptionPane.PLAIN_MESSAGE);
a=V+G+E;
JOptionPane.showMessageDialog(null, "Total Sold:"
+t, "Sold",JOptionPane.PLAIN_MESSAGE);
Z=t-a;
JOptionPane.showMessageDialog(null, "Total Profit:"
+Z, "Profit",JOptionPane.PLAIN_MESSAGE);
String print1= "Your Total budget"+a+"\n Selling of Betal
leaf:"+V+"\n Selling Price of Mints"+G+"\n selling Price of Softdrinks"+E+"\n
Total sold"+t+"\n Total Profit"+Z;
{JOptionPane.showMessageDialog(null,print1);}
String message1=String.format("TotalBudget:"+a+"\n Total
sold: "+t+"\n Total profit:"+Z);
JOptionPane.showMessageDialog(null,message1);

}
}

Output
CODE: Interest
INPUT:
import javax.swing.JOptionPane;
public class DBBL {

public static void main (String args[])


{String S=JOptionPane.showInputDialog(null,"please enter amount");
double amount=Double.parseDouble(S);
double principle;
double rate=.01;
for(int day=1;day<=3;day++) {
principle=amount*Math.pow(1+rate,day);
String a =String.format("%.2f",principle);
JOptionPane.showMessageDialog(null,a);

}
}

} OUTPUT:
Code: Car loan
Input: public class Car_loan {

public static void main(String[] args)


{
int carLoan = 100000;
int loanLength = 3;
int interestRate = 5;
int downPayment = 20000;

if (loanLength <= 0 || interestRate <= 5) if (loanLength <= 0 ||


interestRate <= 0)
{
System.out.println("Error! You must take out a valid car loan.");
}
else if (downPayment >= carLoan)
{
System.out.println("The car can be paid in full.");
}
else
{
int remainingBalance = carLoan - downPayment;
int months = loanLength * 12;
int monthlyBalance = remainingBalance / months;
int interest = (monthlyBalance * interestRate) / 100;
int monthlyPayment = (monthlyBalance + interestRate);
System.out.println(monthlyPayment);
}
}

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:") ;

String password = "please let me go";


Scanner scanner = new Scanner (System.in);
String guess = scanner.nextLine();
while (! guess.contentEquals(password)) {
System.out.println("please guess the password:") ;
guess = scanner.nextLine();{
System.out.println ("congratilation") ;

}
}
}
}

Output:

please guess the password:


bjfhfghrgk
please guess the password:
please let me go
congratilation
Code: Random number
Input:

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;

public class work {

public static void main (String args[]) {


int age=5;
switch (age) {

case 1: JOptionPane.showMessageDialog(null,"he can sing");


break;
case 2: JOptionPane.showMessageDialog(null,"he can walk");
break;
case 3: JOptionPane.showMessageDialog(null,"he can bowling");
break;
case 4: JOptionPane.showMessageDialog(null,"he can batteint");
break;
case 5: JOptionPane.showMessageDialog(null,"he will go to house");
default:
JOptionPane.showMessageDialog(null,"he is no more with us");
break;

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 {

public static void main(String[] args) {


// TODO Auto-generated method stub
String p1=JOptionPane.showInputDialog(null,"Enter my First business :");
String p2=JOptionPane.showInputDialog(null,"Enter my Last :");
String q=String.format("fine, %S %S", p1,p2);
System.out.println(q);
JOptionPane.showMessageDialog(null, q);

Output:
CODE : Challenge
Input:
package assignment;
import javax.swing.JOptionPane;

public class Challange {

public static void main(String[] args) {


// TODO Auto-generated method stub
String p1=JOptionPane.showInputDialog(null,"Enter Your First
chalenges :");
String p2=JOptionPane.showInputDialog(null,"Enter Your Last
chalenges :");
String q=String.format("Welcome, %S %S", p1,p2);
System.out.println(q);
JOptionPane.showMessageDialog(null, q);

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:

You might also like