真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java的一些編寫代碼 java類的代碼

JAVA 編寫完整代碼

public class test1 {

武城ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("請輸入本月稅前工資");

double d = scan.nextDouble(); //稅前工資

double sal= d - 3500; // 減去扣除數(shù)的

double salary = 0; //初始化工資

if(sal=1500){

salary = sal*0.03;

}else if(sal=4500){

salary = sal*0.1-105;

}else if(sal=9000){

salary = sal*0.2-555;

}else if(sal=35000){

salary = sal*0.25-1005;

}else if(sal=55000){

salary = sal*0.3-2755;

}else if(sal=80000){

salary = sal*0.35-5505;

}else{

salary = sal*0.45-13505;

}

System.out.println("個人所得稅的繳納額度為:"+salary+"元");

}

}

盡量簡化邏輯 像錢的多少 先用變量存儲起來 再帶入就好了

盡量簡化代碼? 像輸出也只用一句然后帶入就好了

盡量自己考慮 每一點問題都是自己敲代碼的過程中產(chǎn)生然后明白的

這題是我原題? 我知道你在哪? 既然在那了 為什么還不努力呢

JAVA源代碼的編寫

import java.util.Date;

public class Travel{

TravelLeg mid = new TravelLeg();

private String start;

private String end;

private Date startTime;

private Date endTime;

private String travelId;

private String comment;

public void add(TravelLeg mid){

this.start = mid.getStart();

this.mid = mid;

this.end = mid.getEnd();

}

public boolean check_date(){

if(!mid.getStartTime().before(mid.getEndTime())){

System.out.println("時間錯誤");

return false;

}else return true;

}

public void print(){

System.out.println("開始地點:"+this.start+"中間地點"+this.mid.getEnd()+this.end);

}

}

用java怎么編寫,求全代碼

import?java.util.Scanner;

import?demo.ui.MainShell;

import?demo.ui.PublicStatic;

public?class?DemoApp?{

public?static?int?getScanner()?{

int?input?=?0;

try?{

Scanner?scanner?=?new?Scanner(System.in);

input?=?scanner.nextInt();

}?catch?(Exception?e)?{

System.out.println("\t\t請重新輸入");

return?getScanner();

}

return?input;

}

public?static?void?main(String[]?args)?{

System.out.println("\t\t\t歡迎使用系統(tǒng)");

System.out.println("\t\t***********************");

System.out.println("\t\t\t1、客戶信息管理");

System.out.println("\t\t\t2、購物結(jié)算");

System.out.println("\t\t\t3、真情回饋");

System.out.println("\t\t\t4、注銷");

System.out.println("\t\t***********************");

while(true)?{

int?input?=?getScanner();

switch?(input)?{

case?1:

System.out.println("\t\t\t1、客戶信息管理");

break;

case?2:

System.out.println("\t\t\t2、購物結(jié)算");

break;

case?3:

System.out.println("\t\t\t3、真情回饋");

break;

case?4:

System.out.println("\t\t\t4、注銷");

break;

default:

System.out.println("\t\t請重新輸入");

break;

}

if(input?==?4)?{

break;

}

}

}

}

利用java編寫代碼實現(xiàn)如下功能,需要全部代碼

很簡單的應(yīng)用,為了節(jié)省字數(shù),代碼注釋我就不加了

首先是顯示層,LoinWindow:

import?java.awt.FlowLayout;

import?java.awt.GridBagConstraints;

import?java.awt.GridBagLayout;

import?java.awt.GridLayout;

import?java.awt.event.ActionEvent;

import?java.awt.event.ActionListener;

import?java.awt.event.FocusEvent;

import?java.awt.event.FocusListener;

import?javax.swing.JButton;

import?javax.swing.JFrame;

import?javax.swing.JLabel;

import?javax.swing.JOptionPane;

import?javax.swing.JPanel;

import?javax.swing.JTextField;

import?javax.swing.border.EmptyBorder;

public?class?LoinWindow?extends?JFrame?implements?ActionListener,?FocusListener?{

private?JPanel?mainPanel,?namePanel,?btnPanel;

private?JTextField?tfName,?tfPsd;

private?JButton?btnLogin,?btnCancel;

private?static?final?int?WIDTH?=?300;

private?static?final?int?HEIGHT?=?200;

private?LoginService?service?=?new?LoginService();

public?LoinWindow()?{

super("登錄窗體");

}

public?void?launch()?{

setSize(WIDTH,?HEIGHT);

setVisible(true);

setDefaultCloseOperation(EXIT_ON_CLOSE);

GridLayout?mainLayout?=?new?GridLayout(2,?1);

mainLayout.setVgap(10);

mainPanel?=?new?JPanel(mainLayout);

GridBagLayout?nameLayout?=?new?GridBagLayout();

namePanel?=?new?JPanel(nameLayout);

namePanel.setBorder(new?EmptyBorder(10,?10,?10,?10));

JLabel?nameLabel?=?new?JLabel("姓名:");

tfName?=?new?JTextField();

JLabel?psdLabel?=?new?JLabel("密碼:");

tfPsd?=?new?JTextField();

JLabel?blank?=?new?JLabel("?");

namePanel.add(nameLabel);

namePanel.add(tfName);

namePanel.add(blank);

namePanel.add(psdLabel);

namePanel.add(tfPsd);

GridBagConstraints?s?=?new?GridBagConstraints();

s.fill?=?GridBagConstraints.BOTH;

s.gridwidth?=?1;

s.weightx?=?0;

s.weighty?=?0;

nameLayout.setConstraints(nameLabel,?s);

s.gridwidth?=?0;

s.weightx?=?1;

s.weighty?=?0;

nameLayout.setConstraints(tfName,?s);

s.gridwidth?=?0;

s.weightx?=?4;

s.weighty?=?0;

nameLayout.setConstraints(blank,?s);

s.gridwidth?=?1;

s.weightx?=?0;

s.weighty?=?0;

nameLayout.setConstraints(psdLabel,?s);

s.gridwidth?=?3;

s.weightx?=?1;

s.weighty?=?0;

nameLayout.setConstraints(tfPsd,?s);

FlowLayout?btnLayout?=?new?FlowLayout();

btnLayout.setAlignment(FlowLayout.CENTER);

btnPanel?=?new?JPanel(btnLayout);

btnLogin?=?new?JButton("確定");

btnCancel?=?new?JButton("取消");

btnPanel.add(btnLogin);

btnPanel.add(btnCancel);

btnCancel.addActionListener(this);

btnLogin.addActionListener(this);

mainPanel.add(namePanel);

mainPanel.add(btnPanel);

setContentPane(mainPanel);

tfName.addFocusListener(this);

tfPsd.addFocusListener(this);

pack();

setSize(WIDTH,?HEIGHT);

setLocationRelativeTo(null);

}

@Override

public?void?actionPerformed(ActionEvent?e)?{

Object?source?=?e.getSource();

if(source?==?btnCancel)?{

System.exit(0);

}?else?if(source?==?btnLogin)?{

String?username?=?tfName.getText();

String?password?=?tfPsd.getText();

boolean?success?=?service.login(username,?password);

if(success)?{

warn("成功",?"登錄成功!");

}?else?{

warn("失敗",?"您輸入的用戶名或密碼錯誤?!");

}

}

}

@Override

public?void?focusGained(FocusEvent?arg0)?{

}

@Override

public?void?focusLost(FocusEvent?e)?{

Object?source?=?e.getSource();

if(source?==?tfName)?{

String?username?=?tfName.getText();

try?{

service.matchUsername(username);

}?catch?(LoginException?e1)?{

warn("驗證錯誤",?e1.getMessage());

}

}?else?if(source?==?tfPsd)?{

String?password?=?tfPsd.getText();

try?{

service.matchPassword(password);

}?catch?(LoginException?e1)?{

warn("驗證錯誤",?e1.getMessage());

}

}

}

private?void?warn(String?title,?String?msg)?{

JOptionPane.showMessageDialog(null,?msg,?title,?JOptionPane.INFORMATION_MESSAGE);

}

public?static?void?main(String[]?args)?{

new?LoinWindow().launch();

}

}

然后是模型層:LoginDao

public?class?LoginDao?{

public?boolean?login(String?username,?String?password)?{

if(username.equals("admin")??password.equals("12345"))?{

return?true;

}

return?false;

}

}

LoginService

import?java.util.regex.Pattern;

public?class?LoginService?{

private?static?final?Pattern?LOGIN_PATTERN?=?Pattern.compile("[a-zA-Z]+");

private?static?final?Pattern?PASSWORD_PATTERN?=?Pattern.compile("[1-9]+");

private?LoginDao?dao?=?new?LoginDao();

public?boolean?matchUsername(String?username)?throws?LoginException?{

if(null?==?username?||?username.isEmpty())?{

return?false;

}

if(!LOGIN_PATTERN.matcher(username).matches())?{

throw?new?LoginException("您輸入的用戶名不合法,請輸入英文!");

}

return?true;

}

public?boolean?matchPassword(String?password)?throws?LoginException?{

if(null?==?password?||?password.isEmpty())?{

return?false;

}

if(!PASSWORD_PATTERN.matcher(password).matches())?{

throw?new?LoginException("您輸入的密碼不合法,請輸入數(shù)字!");

}

return?true;

}

public?boolean?login(String?username,?String?password)?{

if(null?==?username?||?username.isEmpty())?{

return?false;

}

if(null?==?password?||?password.isEmpty())?{

return?false;

}

if(!dao.login(username,?password))?{

return?false;

}

return?true;

}

}

LoginException

public?class?LoginException?extends?Exception?{

public?LoginException(String?arg0)?{

super(arg0);

}

}

不知道分層設(shè)計思想是不是我想的這樣


網(wǎng)站欄目:java的一些編寫代碼 java類的代碼
新聞來源:http://weahome.cn/article/dooggcs.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部