摘要:一超市購物程序超市購物程序你要買什么輸入買多少份輸入的不是商品號(hào)還要買嗎要買輸入,不買輸入總共花了總共花了二登陸注冊(cè)
import java.util.Scanner;public class test2_3 { //超市購物程序 static double cash=0.0; public static double buy(){ System.out.println("你要買什么?輸入id"); Scanner scanner=new Scanner(System.in); int id=1; id=scanner.nextInt(); System.out.println("買多少份?"); int num=scanner.nextInt(); switch (id){ default: System.out.println("輸入的不是商品號(hào)"); break; case 1: cash+=8.8*num; break; case 2: cash+=10.0*num; break; case 3: cash+=18.8*num; break; case 4: cash+=12.5*num; break; case 5: cash+=15.5*num; } return cash; } public static void main(String[] args) { buy(); Scanner scanner=new Scanner(System.in); String choicey="Y"; String choicen="N"; System.out.println("還要買嗎?要買輸入Y,不買輸入N"); String ch=scanner.nextLine(); if(ch.equals(choicey)){ cash=buy(); } else if(ch.equals(choicen)){ System.out.println("總共花了"+cash); System.exit(1); } System.out.println("總共花了"+cash); }}
import java.util.HashMap;import java.util.Scanner;public class test2_6 { static HashMap<Integer,String> message=new HashMap<>();public static void login(){ System.out.println("這里是登陸界面"); System.out.println("請(qǐng)輸入賬號(hào)密碼"); Scanner scanner=new Scanner(System.in); int number=scanner.nextInt(); Scanner scanner1=new Scanner(System.in); String password=scanner1.nextLine(); if(message.get(number).equals(password)){ System.out.println("登陸成功"); } else { System.out.println("密碼不對(duì)哦,或者賬號(hào)不存在"); }}public static void register(){ System.out.println("這里是注冊(cè)界面"); System.out.println("請(qǐng)輸入賬號(hào)和密碼一行一個(gè),賬號(hào)不能重復(fù),長(zhǎng)度僅限6位數(shù)"); System.out.println("tips:賬號(hào)純數(shù)字,密碼你隨意"); System.out.println("先輸入賬號(hào)吧,寶兒"); Scanner scanner=new Scanner(System.in); int number=scanner.nextInt(); System.out.println("輸密碼"); Scanner scanner1=new Scanner(System.in); String password=scanner1.nextLine(); message.put(number, password);}public static void check(){ System.out.println(message);}public static void exit(){System.exit(0);} public static void main(String[] args) { while (true){ System.out.println("這里是登陸注冊(cè)案例"); System.out.println("請(qǐng)選擇要做的操作:"); System.out.println("1.登陸"); System.out.println("2.注冊(cè)"); System.out.println("3.查看"); System.out.println("4.退出"); Scanner scanner=new Scanner(System.in); int choice=scanner.nextInt(); switch (choice){ default: System.out.println("選錯(cuò)了。再來"); break; case 1: login(); break; case 2: register(); break; case 3: check(); break; case 4: exit(); break; } } }}
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/121122.html
摘要:前言最近太忙,代碼不做過多解釋,如有不懂的地方歡迎底下評(píng)論留言或提問。 前言 最近太忙,代碼不做過多解釋,如有不懂的地方歡迎底下評(píng)論留言或+qq 258111627...
摘要:一圖形的面積與周長(zhǎng)計(jì)算程序輸入計(jì)算圓的周長(zhǎng)面積輸入計(jì)算長(zhǎng)方形的周長(zhǎng)面積輸入圓的周長(zhǎng)依次輸入長(zhǎng)方形的長(zhǎng)和寬面積是周長(zhǎng)是面積是周長(zhǎng)是二案例經(jīng)理與員工工資代碼經(jīng)理工資普通員工工資 ...
摘要:個(gè)人前端文章整理從最開始萌生寫文章的想法,到著手開始寫,再到現(xiàn)在已經(jīng)一年的時(shí)間了,由于工作比較忙,更新緩慢,后面還是會(huì)繼更新,現(xiàn)將已經(jīng)寫好的文章整理一個(gè)目錄,方便更多的小伙伴去學(xué)習(xí)。 showImg(https://segmentfault.com/img/remote/1460000017490740?w=1920&h=1080); 個(gè)人前端文章整理 從最開始萌生寫文章的想法,到著手...
摘要:目前,中關(guān)村黑馬程序員訓(xùn)練營(yíng)已成長(zhǎng)為行業(yè)學(xué)員質(zhì)量好課程內(nèi)容深企業(yè)滿意的移動(dòng)開發(fā)高端訓(xùn)練基地,并被評(píng)為中關(guān)村軟件園重點(diǎn)扶持人才企業(yè)。黑馬程序員的學(xué)員篩選制度,遠(yuǎn)比現(xiàn)在以上的企業(yè)招聘流程更為嚴(yán)格。系統(tǒng)的學(xué)習(xí)可以參考w3c的教程 web概念概述 * JavaWeb: * 使用Java語言開發(fā)基于互聯(lián)網(wǎng)的項(xiàng)目 * 軟件架構(gòu): 1. C/S: Client/Server 客戶端/服務(wù)...
閱讀 2538·2021-11-25 09:43
閱讀 2668·2021-11-16 11:50
閱讀 3333·2021-10-09 09:44
閱讀 3264·2021-09-26 09:55
閱讀 2870·2019-08-30 13:50
閱讀 1064·2019-08-29 13:24
閱讀 2122·2019-08-26 11:44
閱讀 2846·2019-08-26 11:37