内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

請(qǐng)輸入性別的Java代碼 運(yùn)行查詢時(shí)提示請(qǐng)輸入性別

java如何通過(guò)鍵盤(pán)輸入性別代號(hào)

//用Scanner讀入字符串,加個(gè)判斷就可以了

成都創(chuàng)新互聯(lián)主營(yíng)尚志網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶APP開(kāi)發(fā)公司,尚志h5微信小程序搭建,尚志網(wǎng)站營(yíng)銷(xiāo)推廣歡迎尚志等地區(qū)企業(yè)咨詢

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

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

String?sex=s.next();

if(sex.toLowerCase().equals("m"))

System.out.println("男性");

else?if(sex.toLowerCase().equals("n"))

System.out.println("女性");

else

System.out.println("未知");

}

java程序設(shè)計(jì),用scanner編寫(xiě),輸入姓名,性別,年齡,住址,婚否,可以輸出相應(yīng)的數(shù)據(jù)?

package?test;

import?java.util.Scanner;??//?Import?the?Scanner?class

public?class?Test{

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

Scanner?myObj?=?new?Scanner(System.in);??//?Create?a?Scanner?object

System.out.print("輸入年齡:");

String?age=?myObj.nextLine();??//?Read?user?input

System.out.print("輸入姓名:");

String?name=?myObj.nextLine();??//?Read?user?input

//再寫(xiě)?地點(diǎn)。。。

System.out.println(name+"?你好,今年"?+?age+"歲");??//?Output?user?input

}}

用JAVA編寫(xiě)一個(gè)程序,要求如下:

實(shí)現(xiàn)代碼如下:

Student類:

public class Student {

private String name;

private String sex;

private int age;

private double chinese;

private double math;

private double english;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getSex() {

return sex;

}

public void setSex(String sex) {

this.sex = sex;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public double getChinese() {

return chinese;

}

public void setChinese(double chinese) {

this.chinese = chinese;

}

public double getMath() {

return math;

}

public void setMath(double math) {

this.math = math;

}

public double getEnglish() {

return english;

}

public void setEnglish(double english) {

this.english = english;

}

}

-----------------------------------------------------------------

StudentTest類:(測(cè)試類)

import java.util.Scanner;

public class StudentTest {

public static void main(String[] args) {

Student student = new Student();

Scanner sc = new Scanner(System.in);

System.out.println("請(qǐng)輸入姓名:");

student.setName(sc.next());

System.out.println("請(qǐng)輸入性別:");

student.setSex(sc.next());

System.out.println("請(qǐng)輸入年齡:");

student.setAge(sc.nextInt());

System.out.println("請(qǐng)輸入語(yǔ)文成績(jī)、數(shù)學(xué)成績(jī)、英語(yǔ)成績(jī):");

student.setChinese(sc.nextDouble());

student.setMath(sc.nextDouble());

student.setEnglish(sc.nextDouble());

Double count = student.getChinese()+ student.getMath()+student.getEnglish();

System.out.println("姓名:"+student.getName()+" 性別:"+student.getSex()+" 年齡:"+student.getAge());

System.out.println("總分:"+count+" 平均分:"+count/3);

}

}

運(yùn)行結(jié)果為:

新聞標(biāo)題:請(qǐng)輸入性別的Java代碼 運(yùn)行查詢時(shí)提示請(qǐng)輸入性別
網(wǎng)站路徑:http://www.rwnh.cn/article18/ddcpsdp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷(xiāo)型網(wǎng)站建設(shè)外貿(mào)建站、ChatGPT用戶體驗(yàn)、網(wǎng)站排名自適應(yīng)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司
华亭县| 伽师县| 肃宁县| 遵化市| 阿合奇县| 缙云县| 大兴区| 吉水县| 遂川县| 道孚县| 吴川市| 保亭| 洪洞县| 浙江省| 南陵县| 平利县| 新宁县| 武冈市| 汶上县| 江都市| 镇原县| 平凉市| 西贡区| 巴南区| 大方县| 漾濞| 越西县| 普兰县| 洞头县| 济宁市| 江达县| 卓资县| 高州市| 天水市| 司法| 青龙| 洮南市| 南华县| 安达市| 阜宁县| 运城市|