第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何調(diào)用total的值,并輸出

如何調(diào)用total的值,并輸出

菜鳥555 2016-03-26 11:07:24
import javax.swing.JOptionPane;public class Student { String xh,name; int yy,math,yw,total; Student(String xh1,String name1){ xh=xh1; name=name1; } Student(String xh1,String name1,int yy1,int math1,int yw1){ xh=xh1; name=name1; yy=yy1; math=math1; yw=yw1; } public void display(){ String str=JOptionPane.showInputDialog("請(qǐng)輸入英語成績:"); yy=Integer.parseInt(str); str=JOptionPane.showInputDialog("請(qǐng)輸入數(shù)學(xué)成績:"); math=Integer.parseInt(str); str=JOptionPane.showInputDialog("請(qǐng)輸入語文成績:"); yw=Integer.parseInt(str); JOptionPane.showMessageDialog(null,"學(xué)號(hào):"+xh+"\n姓名:"+name+"\n數(shù)學(xué):"+math+"\n英語:"+yy+"\n語文:"+yw+"\n總成績"+total); } public void sum(){ total=yy+yw+math; } public static void main(String[] args) { Student t1=new Student("xxx", "xxx"); t1.display(); } }
查看完整描述

1 回答

?
littleOStar

TA貢獻(xiàn)28條經(jīng)驗(yàn) 獲得超4個(gè)贊

看圖

http://img1.sycdn.imooc.com//5726d2ac00016bea07660427.jpg


你只是聲明了全局變量, 但沒有調(diào)用

查看完整回答
反對(duì) 回復(fù) 2016-05-02
  • 1 回答
  • 0 關(guān)注
  • 1329 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)