0% found this document useful (0 votes)
29 views6 pages

Import Public Class Public Static Void Null: "Welcome To North South University MIS Class"

The document contains 10 code snippets written in Java that demonstrate different programming concepts like input/output, conditional statements, formatting strings, and message dialogs. The code snippets include programs to welcome users, get name input, calculate sums and totals, check temperatures, and determine grades based on marks. Overall the document shows examples of basic Java programming.
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)
29 views6 pages

Import Public Class Public Static Void Null: "Welcome To North South University MIS Class"

The document contains 10 code snippets written in Java that demonstrate different programming concepts like input/output, conditional statements, formatting strings, and message dialogs. The code snippets include programs to welcome users, get name input, calculate sums and totals, check temperatures, and determine grades based on marks. Overall the document shows examples of basic Java programming.
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/ 6

1

import javax.swing.JOptionPane;
public class a
{public static void main(String agrs[])
{JOptionPane.showMessageDialog(null, "Welcome to North South University MIS Class");
}
}

2
import java.util.Scanner;
public class b
{public static void main(String argl[])
{ Scanner input=new Scanner(System.in);
System.out.print("Please Enter Your First Name:");
String Firstname=input.nextLine();
System.out.print("Please Enter Your Last Name:");
String Lastname=input.nextLine();
String message=String.format("Best of Luck %S %S" ,Firstname,Lastname);
System.out.print(message);
}
}

3
import javax.swing.JOptionPane;
public class c
{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("best of luck %S",firstname,lastname);
JOptionPane.showMessageDialog(null,message);
}
}
4
import java.util.Scanner;
public class d
{public static void main(String args[])
{Scanner input=new Scanner(System.in);
int a,b,c,d,e,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();
System.out.print("Enter E:");
e = input.nextInt();
sum=((((a*b)+c)-d)/e);
System.out.printf("sum is %d",sum);
}
}

5
import javax.swing.JOptionPane;
public class e
{public static void main(String args[])
{String a,b,c;
double p,q,r,Total;
a=JOptionPane.showInputDialog("Enter p:");
p=Integer.parseInt(a);
b=JOptionPane.showInputDialog("Enter q:");
q=Integer.parseInt(b);
c=JOptionPane.showInputDialog("Enter r:");
r=Integer.parseInt(c);
Total=p-(q-r);
JOptionPane.showMessageDialog(null,"Total is "+ Total);
}
}
6
import java.util.Scanner;
public class f
{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:");
x=input.nextFloat();
System.out.print("Enter Rice purched in Kg:");
a=input.nextFloat();
System.out.print("Enter price of Milk per:");
y=input.nextFloat();
System.out.print("Enter Milk purched 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:"+r);
}
}
7
import javax.swing.JOptionPane;
public class g
{public static void main(String args[])
{String p,q,s,u,v;
int x,y,a,b,z,t,r,n,m;
p=JOptionPane.showInputDialog("Total Budget:");
z=Integer.parseInt(p);
q=JOptionPane.showInputDialog("Enter Price of Rice per kg:");
x=Integer.parseInt(q);
s=JOptionPane.showInputDialog("Amount of Rice purchased in KG:");
a=Integer.parseInt(s);
m=x*a;
JOptionPane.showMessageDialog(null,"Total Price of Rice:"+m,"Rice",
JOptionPane.PLAIN_MESSAGE);
u=JOptionPane.showInputDialog("Enter Price of Milk per ltr:");
y=Integer.parseInt(u);
v=JOptionPane.showInputDialog("Amount of Milk purchased in ltr:");
b=Integer.parseInt(v);
n=y*b;
JOptionPane.showMessageDialog(null,"Total Price of Milk:"+n);
JOptionPane.showMessageDialog(null,"Total Budget:"+z,"Budget",
JOptionPane.PLAIN_MESSAGE);
t=m+n;
JOptionPane.showMessageDialog(null,"Total Spending:"+t,"Spending",
JOptionPane.PLAIN_MESSAGE);
r=z-t;
JOptionPane.showMessageDialog(null,"Remaining:"+r,"Remaining",JOptionPane.PLAIN_MESS
AGE);
String print="Your total budget:"+z+"\n price of Rice:"+m+" \n,price of milk:"+n+"\n,
You Spent a total of:"+t+"\n, Remaining:"+r;
//(({JOptionPane.showMessageDialog(null,Print);}))
String message=String.format("Total budget"+z+"\n Total Spending"+t+"\n Total
Remaining"+r);
//((JOptionPane.showMessageDialog(null,message);))
}
}
8
import javax.swing.JOptionPane;
public class h
{public static void main(String args[])
{String p,q,s,u,v,o,k,g,h;
int x,y,a,b,t,r,z,n,m,e,i,j,c,w,l,d;
p=JOptionPane.showInputDialog("Total Investment:");
z=Integer.parseInt(p);
q=JOptionPane.showInputDialog("Enter Price of Rice purchased per kg:");
x=Integer.parseInt(q);
s=JOptionPane.showInputDialog("Amount of Rice purchased in KG:");
a=Integer.parseInt(s);
m=x*a;
o=JOptionPane.showInputDialog("Enter Price of Rice sold per kg:");
i=Integer.parseInt(o);
k=JOptionPane.showInputDialog("Amount of Rice sold in KG:");
j=Integer.parseInt(k);
e=i*j;
JOptionPane.showMessageDialog(null,"Total Price of Rice purchased:"+m,"Rice",
JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null,"Total Price of Rice sold:"+e,"Rice",
JOptionPane.PLAIN_MESSAGE);
u=JOptionPane.showInputDialog("Enter Price of Milk purchased per ltr:");
y=Integer.parseInt(u);
v=JOptionPane.showInputDialog("Amount of Milk purchased in ltr:");
b=Integer.parseInt(v);
n=y*b;
g=JOptionPane.showInputDialog("Enter Price of Milk sold per ltr:");
c=Integer.parseInt(g);
h=JOptionPane.showInputDialog("Amount of Milk sold in ltr:");
w=Integer.parseInt(h);
l=c*w;
JOptionPane.showMessageDialog(null,"Total Price of Milk
purchased:"+n,"Milk",JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null,"Total Price of Milk
sold:"+l,"Milk",JOptionPane.PLAIN_MESSAGE);
t=m+n;
JOptionPane.showMessageDialog(null,"Total Spending:"+t,"Spending",
JOptionPane.PLAIN_MESSAGE);
d=e+l;
JOptionPane.showMessageDialog(null,"Total Sold:"+d,"Sold",
JOptionPane.PLAIN_MESSAGE);
r=d-t;
JOptionPane.showMessageDialog(null,"Profit:"+r,"Profit",JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null,"Remaining:"+r,"Remaining",JOptionPane.PLAIN_MESS
AGE);
String print="Total Investment:"+z+"\n,price of Rice purchased:"+m+" \n,price of milk
purchased:"+n+"\n, price of Rice sold:"+e+"\n, price of milk sold:"+l+"\n, You Sold a
total of:"+d+"\n, Profit:"+r;
//(({JOptionPane.showMessageDialog(null,Print);}))
String message=String.format("Total Spending"+t+"\n Total Sold"+d+"\n Total
Profit"+r);
//((JOptionPane.showMessageDialog(null,message);))
}
}
9

import javax.swing.JOptionPane;
public class Thermometer
{public static void main(String args[])
{double temperature=99;
if(temperature>=100);
{System.out.println("You're Sick");}
else
{System.out.println("You're Okay");}
}
}

10
import java.util.Scanner;
public class gradePOINT
{public static void main(String args[])
{Scanner input=new Scanner(System.in);
double x;
System.out.println("Enter Mark:");
x=input.nextDouble();
if(x>=90)
System.out.println("You got A:");
else if(x>=80)
System.out.println("You got B:");
else if(x>=70)
System.out.println("You got C:");
else if(x>=60)
System.out.println("You got D:");
else if(x<60)
System.out.println("You Failed:");
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy