十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊
量身定制 + 運營維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
public class AccountBookTest {
十載的博山網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整博山建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)公司從事“博山網(wǎng)站設(shè)計”,“博山網(wǎng)站推廣”以來,每個客戶項目都認(rèn)真落實執(zhí)行。
public static void main(String[] args) {
// TODO Auto-generated method stub
AccountBook account = new AccountBook("張三",30,10);
System.out.println("賬戶名稱:" + account.accountName + "收入額:" + account.income + "支出額:" + account.outcome + "余額:" + account.compute(account.income, account.outcome));
}
}
class AccountBook{
String accountName;
double income;
double outcome;
AccountBook(String accountName,double income,double outcome)
{
this.accountName = accountName;
if(income 0)
{
this.income = income;
}
else{
System.out.println("收入不能為負(fù)數(shù)!");
}
if(outcome 0)
{
this.outcome = outcome;
}
else{
System.out.println("支出不能為負(fù)數(shù)!");
}
}
public double compute(double income,double outcome)
{
double balance = 0.0;
balance = income - outcome;
return balance;
}
}
給你思路:
你在每個輸入框上都綁定事件,事件中去處理相關(guān)的數(shù)據(jù),再將數(shù)據(jù)顯示到控件上 就可以了
老板,有用的話別忘采納和點贊喲,給我個小小支持。
先上代碼:
public static void main(String[] args) {
int result = 0;
Scanner scanner = new Scanner(System.in);
System.out.println("請輸入要統(tǒng)計的字符竄:");
String str = scanner.nextLine();
System.out.println("input:"+str);
String arrays[] = str.split(" ");
for (int i = 0; i arrays.length; i++) {
if (!arrays[i].contains("-")) {
result += getNumbers(arrays[i]);
}else {
result -= getNumbers(arrays[i]);
}
}
System.out.println("output:"+result);
}
//截取數(shù)字
public static int getNumbers(String content) {
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
return Integer.parseInt(matcher.group(0));
}
return 0;
}
運行效果: