Java Learning Note 11

Source: Internet
Author: User

 PackageWelcome;ImportJava.util.Scanner;/** Algebraic problems: Solving 2x2 linear equations*/ Public classcomputelinearequation { Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); System.out.print ("Enter A, B, C, D, E, F:"); DoubleA =in.nextdouble (); Doubleb =in.nextdouble (); Doublec =in.nextdouble (); DoubleD =in.nextdouble (); DoubleE =in.nextdouble (); Doublef =in.nextdouble (); Doublex = 0; Doubley = 0; if(A * d-b * c! = 0) {x= (E * d-b * f)/(A * d-b *c); Y= (A * F-E * c)/(A * d-b *c); } Else{System.out.println ("The equation has no solution"); System.exit (0); } System.out.println ("X is" + x + "and Y are" +y); }}
 PackageWelcome;ImportJava.util.Scanner;/** Game: Learn to add*/ Public classtestaddition { Public Static voidMain (string[] args) {intA = (int) (Math.random () * 100); intB = (int) (Math.random () * 100); Scanner in=NewScanner (system.in); System.out.print ("What's" + A + "add" + B + "?"); intGuess =In.nextint (); if(A + b = =guess) {System.out.println ("True"); }Else{System.out.println ("False"); }    }}
 PackageWelcome;ImportJava.util.Scanner;/** Calculate the perimeter of a triangle*/ Public classComputegirth { Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); System.out.print ("Enter three sides of a triangle:"); DoubleA =in.nextdouble (); Doubleb =in.nextdouble (); Doublec =in.nextdouble (); DoubleG = 0; if(A + B > C && a + C > B && B + C >a) {G= A + B +C; }Else{System.out.println ("The input is illegal"); System.exit (0); } System.out.println ("The triangle has a circumference of" +G); }}

Java Learning Note 11

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.