1. From the console to enter the students Wang Hao 3 course results, write program implementation
Chengji
(1) The difference between the scores of the math class and the English class
(2) The average score of 3 courses
The code is as follows:
Package Lianxiti;
Import Java.util.Scanner;
Public class Chengji2_5 {
public static void Main (string[] args) {
// TODO auto-generated method stub
/*
* Requirements: input from the console of the college Wang Hao's curriculum achievements, program implementation:
* 1) The difference between the scores of math class and English class
* 2) The average score of 3 courses
*/
Scanner in=new Scanner (System. In );
System. out.println ("Please input Wang Hao's language score:");
int chinese=in.nextint ();
System. out.println ("Please enter Wang Hao's mathematical results");
int math=in.nextint ();
System. out.println ("Please input Wang Hao's English score");
int english=in.nextint ();
System. out. println ("---------------------------------------------------------\ n"+ "language \ t math \ t English \t\n"+ Chinese+ "\ T"+math+ "\ T"+中文版+ "\ n---------------------------------------------------------\ n ");
int cha=math-english; Poor grades in math and English
System. out.println ("math and English poor grades are:" +cha);
int Average= (Chinese+math+english)/3;
System. out.println ( "The average of the classes is:" +average);
}
}
2. The radius of the circle is known radius= 1.5to find its area
Mianji
Tips:
double pi = 3.14159;// Pi
double radius = 1.5;// radius
Double area = pi * radius * RADIUS; Calculate Circle Area
The code is as follows:
Package Lianxiti;
Public class Mianji {
public static void Main (string[] args) {
// TODO auto-generated method stub
/*
* The radius of the known circle is radius=1.5, the area is calculated,
* Hint:
* Double pi=3.14159;
* double=radius=1.5;
* Double Area=pi*radius*radius;
* area is 7.068577499999999
*/
double pi=3.14159;
double radius=1.5;
Double area=pi*radius*radius;
System. out.println (area);
}
}
3.Calculate the number of weeks and the number of days remaining depending on the number of days
Tips:
int days = 46; // days
int week = DAYS/7; // Week
int leftday = days% 7; // number of days left
The code is as follows:
Package Lianxiti;
Public class Genjutianshujisuanzhoushu {
public static void Main (string[] args) {
// TODO auto-generated method stub
/*
* Calculates the number of weeks and the number of days remaining depending on the number of days (46)
* Hint: int days=46;
* int week=days/7;
* int leftday=day%7;
*/
int days=46;
int week=days/7;
int leftday=days%7;
System. out.println ("Total" +days+"weeks" +week+"Number of days left" + leftday);
}
}
4. Implement a digital cipher, the encryption rule is: Encryption result = (integer *10+5 )/2 + 3.14159, the encryption result is still an integer
The code is as follows:
Package pro_0307_01; Import Java.util.Scanner; public class Jiami {public static void main (string[] args) {//enables the user to interact with the console Scanner in=new Scanner (system.in); System.out.println ("Please enter a number:"); Receives data entered from the console, assigns to the variable num int num=in.nextint (); System.out.println ("Original data is:" +num); int num2= (int) ((num*10+5)/2+3.14159); SYSTEM.OUT.PRINTLN ("The result of encryption is:" +num2);}}
Java Learning next day small exercise