Java Experiment One

Source: Internet
Author: User

 
Steps Time consuming H Percentage
Demand analysis 0.3h

7.5

Design 2.5h 62.5
Code implementation 0.5h 12.5
Test 0,2h 5
Analysis Summary 0.5h 12.5

Experiment One

Experiment Two:

Experiment Three

Implement arithmetic

Code:

Import Java.util.Scanner;
public class D1_jisuanqi {
public static void Main (string[] args) {
Double x,y,s;
int i;
System.out.println ("1 is multiplication, 2 is division, 3 is addition, 4 is subtraction, 5 is modulo");
Scanner sc = new Scanner (system.in);
i = Sc.nextint ();
if (i = = 1)
{
System.out.println ("You will use multiplication");
System.out.println ("Please enter x, y two values: (with a space interval)");
Scanner C = new Scanner (system.in);
x = C.nextdouble ();
y = c.nextdouble ();
s = x*y;
System.out.println ("The value of X*y is:" +s);
C.close ();
}
else if (i = = 2)
{
System.out.println ("You will use Division");
System.out.println ("Enter the value of x, Y: (with a space interval)");
Scanner d = new Scanner (system.in);
x = D.nextdouble ();
y = d.nextdouble ();
s = x/y;
SYSTEM.OUT.PRINTLN ("x/y value is:" +s);
D.close ();
}
else if (i = = 3)
{
System.out.println ("You will use addition");
System.out.println ("Enter the value of x, Y: (with a space interval)");
Scanner e = new Scanner (system.in);
x = E.nextdouble ();
y = e.nextdouble ();
s = x+y;
System.out.println ("The value of X+y is:" +s);
E.close ();
}
else if (i = = 4)
{
System.out.println ("You will use subtraction");
System.out.println ("Enter the value of x, Y: (with a space interval)");
Scanner f = new Scanner (system.in);
x = F.nextdouble ();
y = f.nextdouble ();
s = x-y;
SYSTEM.OUT.PRINTLN ("x-y value is:" +s);
F.close ();
}
Else
{
System.out.println ("You will use modulo");
System.out.println ("Enter the value of x, Y (with a space interval)");
Scanner g = new Scanner (system.in);
x = G.nextdouble ();
y = g.nextdouble ();
s = x%y;
System.out.println ("The value of X%y is:" +s);
G.close ();
}
Sc.close ();
}
}

Package LJP;

Import Java.util.Scanner;

public class Hello {

public static void Main (string[] agrs) {

System.out.println ("Input Your first name,please:");

Scanner s =new Scanner (system.in);

String name = S.next ();

System.out.println ("Hello" +name+ "!");

}

Java Experiment One

Related Article

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.