有 4 個 java 文銷亮件,分別是 Shape.java,Square.java,茄侍Circle.java,ShapeTest.java。其顫斗吵內(nèi)容如下:
站在用戶的角度思考問題,與客戶深入溝通,找到高臺網(wǎng)站設(shè)計與高臺網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、國際域名空間、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋高臺地區(qū)。
Shape.java
package graphics;
interface class Shape {
double getArea();
double getPerimeter();
}
Square.java:
package graphics;
public class Square implements Shape {
private double x;
private double y;
private double width;
private double height;
public Square(double x, double y, double width, double height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public Square(double x0, double y0, double x1, double y1) {
double xmin = x0 x1 ? x1 : x0;
double ymin = y0 y1 ? y1 : y0;
this.x = xmin;
this.y = ymin;
this.width = x0 + x1 - 2*xmin;
this.height = y0 + y1 - 2*ymin;
}
@Override
public double getArea() {
return this.width * this.height;
}
@Override
public double getPerimeter() {
return 2 * (this.width + this.height);
}
}
寫了一個代碼,代碼如下,可以進行參考
public?class?sum?{
public?static?void?main(String[]?args)?{
//創(chuàng)建一個Scanner的對象input
Scanner?input?=?new?Scanner(System.in);?
//提示用戶輸入數(shù)據(jù)?
System.out.print("請輸入族孝一個整數(shù)");
//將輸入的值賦給n
int?n?=?input.nextInt();
//定義變量接收計算后的和
int?sum?=?0;
//利用循環(huán)進行求和
for?(int?i?=?0;?i?兆掘稿=?n;?i++)?{
sum+=i;
}
//輸出最后的和
System.out.println("從0一直到散蔽"+n+"的所有整數(shù)的和是:"+sum);
}
}
算是最簡單的吧
package cn.job01;
import java.util.Scanner;
public class Lx07 {
public static void choice() {
System.out.println("登陸菜單 ");
System.out.println("1登陸宏肆粗系統(tǒng)");
System.out.println("2退出");
}
static void choice1() {
System.out.println("購物管理系統(tǒng)客戶信息");
System.out.println("1顯示所有客戶信息");
System.out.println("2添加客戶信息");
System.out.println("3修改客戶信息");
System.out.println("4查詢客戶信息");
}
static void choice2() {
System.out.println("購物管理系統(tǒng)真情回饋");
System.out.println("1幸運大放送");
System.out.println("2幸運抽獎");
System.out.println("3生日問候");
}
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
System.out.println("請輸入1or2");
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜單");
System.out.println("1客戶信息管雹衫理");
System.out.println("蔽鎮(zhèn)2購物結(jié)算");
System.out.println("3真情回饋");
System.out.println("4注銷");
break;
}
System.out.println("選擇輸入數(shù)字");
int num1 = input.nextInt();
switch (num1) {
case 1:
choice1();
break;
case 2:
System.out.println("購物結(jié)算");
break;
case 3:
choice2();
break;
case 4:
choice();
break;
}
}
}