Sie sind auf Seite 1von 3

import java.util.

*; public class ASSIGN { static double n1,n2,n3,n4,n5,sum,diff,pro,quo; public static void main(String[] args) { Scanner input= new Scanner(System.in); System.out.println("\nWELCOME!"); System.out.println("\n Please Enter the First Number:"); n1=input.nextDouble(); System.out.println("\nEnter Second Number:"); n2=input.nextDouble(); sum=n1+n2; System.out.println("\nThe Sum is:"+ sum); System.out.println("\nEnter the Third Number"); n3=input.nextDouble(); diff=sum-n3; System.out.println("\nThe Difference of the Sum and the 3rd num is:"+ diff); System.out.println("\nEnter the Fourth Number:"); n4=input.nextDouble(); pro=diff*n4; System.out.println("\nThe Product of the Difference and the 4th num is,"+ pro); System.out.println("\nEnter the Fifth Number:"); n5=input.nextDouble(); quo=pro/n5; System.out.println("\nThe Qoutient of the Product and the 5th num is:"+ quo); System.out.println("\nTHANK YOU!"); } }

import javax.swing.JOptionPane; public class AssignGUI { static double n1,n2,n3,n4,n5,sum,diff,pro,qou; static String num1, num2, num3, num4, num5; public static void main(String[] args) { num1=JOptionPane.showInputDialog("Enter the First Number:"); num2=JOptionPane.showInputDialog("Enter the Second Number:"); n1=Double.parseDouble(num1); n2=Double.parseDouble(num2); sum=n1+n2; JOptionPane.showMessageDialog(null,sum, "The Sum of the 1st and 2nd num is:", JOptionPane.INFORMATION_MESSAGE); num3=JOptionPane.showInputDialog("Enter the Third Number:"); n3=Double.parseDouble(num3); diff=sum-n3; JOptionPane.showMessageDialog(null,diff, "The Difference of the Sum and 3rd num is:", JOptionPane.INFORMATION_MESSAGE); num4=JOptionPane.showInputDialog("Enter the Fourth Number:");

n4=Double.parseDouble(num4); pro=diff*n4; JOptionPane.showMessageDialog(null,pro, "The Product of the Difference and 4th num is:", JOptionPane.INFORMATION_MESSAGE); num5=JOptionPane.showInputDialog("Enter the Fifth Number:"); n5=Double.parseDouble(num5); qou=pro/n5; JOptionPane.showMessageDialog(null,qou, "The Qoutient of the Product and 5th num is:", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } }

import public static static

java.util.*; class AREEEA { Double side,n1, rad,ac, b,h,ta,w,l,ra; final Double pi=3.141592; public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("\nWELCOME!"); System.out.println("Area of Square"); System.out.println("Enter the Base:"); n1=input.nextDouble(); side=n1*n1; System.out.println("\n\nThe area of the square is:"+ side); System.out.println("Area of Circle"); System.out.println("Enter the Radius:"); rad=input.nextDouble(); ac=pi*rad*rad; System.out.println("\n\nThe Area of the Circle is:"+ ac); System.out.println("Area of Triangle"); System.out.println("Enter the Base:"); b=input.nextDouble(); System.out.println("Enter the height:"); h=input.nextDouble(); ta=b*h/2; System.out.println("\n\nThe area of the Triangle is:"+ ta); System.out.println("Area of Rectangle"); System.out.println("Enter the Width:"); w=input.nextDouble(); System.out.println("Enter the Length:"); l=input.nextDouble(); ra=w*l; System.out.println("\n\n\nThe area of the Rectangle is:"+ System.out.println("THANK YOU!");

ra);

} import public static static static

javax.swing.JOptionPane; class GUI { double side,n1, rad,ac, b,h,ta,w,l,ra; final double pi=3.141592; String num1,num2,num3,num4,num5, num6; public static void main(String[] args) {

num1=JOptionPane.showInputDialog("Enter the Base of the Square:"); n1=Double.parseDouble(num1); side=n1*n1; JOptionPane.showMessageDialog(null,side, "The Area of Square is:", JOptionPane.INFORMATION_MESSAGE); num2=JOptionPane.showInputDialog("Enter the Radius of the Circle:"); rad=Double.parseDouble(num2); ac=pi*rad*rad; JOptionPane.showMessageDialog(null,ac, "The Area of a Circle is:", JOptionPane.INFORMATION_MESSAGE); num3=JOptionPane.showInputDialog("Enter the Base of the Triangle:"); num4=JOptionPane.showInputDialog("Enter the Height of the Triangle:"); b=Double.parseDouble(num3); h=Double.parseDouble(num4); ta=b*h/2; JOptionPane.showMessageDialog(null,ta, "The Area of a Triangle is:", JOptionPane.INFORMATION_MESSAGE); num5=JOptionPane.showInputDialog("Enter the Width of the Rectangle:"); num6=JOptionPane.showInputDialog("Enter the Legth of the Rectangle:"); w=Double.parseDouble(num5); l=Double.parseDouble(num6); ra=w*l; JOptionPane.showMessageDialog(null,ra, "The Area of a Rectangle is:", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } }

Das könnte Ihnen auch gefallen