欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java語言編寫代碼你好 java語言代碼大全及其含義

誰會用JAVA語言寫這個程序?感謝好心人寫好發(fā)照片,謝謝!

我說過幫你完成的,以下是原創(chuàng)代碼:

創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供欒川網(wǎng)站建設(shè)、欒川做網(wǎng)站、欒川網(wǎng)站設(shè)計(jì)、欒川網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、欒川企業(yè)網(wǎng)站模板建站服務(wù),10年欒川做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

package 商品系統(tǒng);

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.util.Scanner;

public class SellSystem {

Goods[] goods=new Goods[1000];

int k;

public SellSystem() throws Exception{

for(int i=0;i1000;i++){goods[i]=new Goods();}

? read();

}

void addgoods(){

String id,name,price,num;

Scanner input=new Scanner(System.in);

System.out.printf("請輸入商品編號:\n"氏笑);

id=input.nextLine();

System.out.printf("請輸入商品名稱\n");

name=input.nextLine();

System.out.printf("請輸入商品價(jià)格:\n");

price=input.nextLine();

System.out.printf("請輸入商品數(shù)量:\n");

num=input.nextLine();

goods[k]=new Goods(id,name,price,num);

k++;

write();

System.out.printf("\n商品添加成功!\n");

}

void deletegoods(String id)

{

int d=find(id);

if(d==-1)

System.out.printf("刪除失侍核灶敗,該商品編號不存在\n");

else{

for(int i=d;i=k;i++)

{

goods[d].id=goods[d+1].id;

goods[d].name=goods[d+1].name;

goods[d].price=goods[d+1].price;

goods[d].num=goods[d+1].num;

}

k--;

write();

}

// System.out.printf(d+"\n");

}

///////////////////////////////////////////////////////////////////////////////////

int find(String goodsId)

{

int index=-1;

for(int i=0;ik;i++)

{

//System.out.printf("\n"+goods[0].id);

if(goods[i].id.equals(goodsId))

{

index=i;

break;

}

}

return index;

}

/////////////////////////////////////////////////////////////////////////////////////

void write()

{

String temp="";

temp=k+" ";

for(int i=0;ik;i++){

temp+=goods[i].id+" "+goods[i].name+" "+goods[i].price+" "+goods[i].num+" ";

}

try {

FileWriter message=new FileWriter("老扮d:/商品信息.txt");

message.write(temp);

message.close();

} catch (IOException e) {

// TODO 自動生成的 catch 塊

e.printStackTrace();

}

}

/////////////////////////////////////////////////////////

boolean read() throws IOException{

String temp="";

String[] strs=null;

boolean flag=true;

try {

FileReader message=new FileReader("d:/商品信息.txt");

BufferedReader reader = new BufferedReader(message);

temp=reader.readLine();

strs = temp.split (" ");

? ? ? ?k=Integer.parseInt(strs[0]);

for(int i=0;ik;i++){

for(int j=1;j=4;j++){

switch(j){

case 1:goods[i].id=strs[i*4+j];break;

case 2:goods[i].name=strs[i*4+j];break;

case 3:goods[i].price=strs[i*4+j];break;

case 4:goods[i].num=strs[i*4+j];break;

}

}

}

} catch (FileNotFoundException e) {

// TODO 自動生成的 catch 塊

e.printStackTrace();

}

return flag;

}

///////////////////////////////////////////////////////////

void print(){

for(int i=0;ik;i++)

System.out.printf("商品編號:"+goods[i].id+"\n商品名稱:"+goods[i].name+"\n商品價(jià)格:"+goods[i].price+"\n商品數(shù)量:"+goods[i].num+"\n----------\n");

}

//////////////////////////////////////////////////////////////////////////////////////

int findp(String price){

int index=-1;

for(int i=0;ik;i++){

if(goods[i].price.equals(price)){

System.out.printf("商品編號:"+goods[i].id+"\n商品名稱:"+goods[i].name+"\n商品價(jià)格:"+goods[i].price+"\n商品數(shù)量:"+goods[i].num+"\n----------\n");

index=1;

}

}

return index;

}

////////////////////////////////////////////////////////////////////////////////

void change(String cid)

{

int j=find(cid);

while(true){

Scanner t=new Scanner(System.in);

System.out.printf("1.修改商品名稱\n");

System.out.printf("2.修改商品價(jià)格\n");

System.out.printf("3.修改商品數(shù)量\n");

System.out.printf("請輸入相應(yīng)的序號進(jìn)行操作:");

int select=t.nextInt();

switch(select){

case 1:

System.out.printf("修改名稱為:");

Scanner w=new Scanner(System.in);

? ?goods[j].name=w.nextLine();

? ?System.out.printf("商品名稱修改成功!\n");break;

case 2:

System.out.printf("修改價(jià)格為:");

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

? ? ? ?goods[j].price=o.nextLine();

? ? ? ?System.out.printf("商品價(jià)格修改成功!\n");break;

case 3:

System.out.printf("修改數(shù)量為:");

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

? ? ? ?goods[j].num=l.nextLine();

? ? ? ?System.out.printf("商品數(shù)量修改成功!\n");break;

?}

System.out.printf("按輸入任意值返回繼續(xù)修改,輸入“0”退出修改\n");

Scanner qq=new Scanner(System.in);

int exit=qq.nextInt();

if(exit==0)break;

write();

}

}

//////////////////////////////////////////////

void menu(){

System.out.printf("商品管理系統(tǒng)\n");

System.out.printf("1.查詢\n");

System.out.printf("2.添加\n");

System.out.printf("3.刪除\n");

System.out.printf("4.修改\n");

System.out.printf("5.退出\n");

System.out.printf("請輸入相應(yīng)的序號進(jìn)行操作:\n");

System.out.printf("------------------------------------\n");

Scanner a=new Scanner(System.in);

int choose1=a.nextInt();

int choose2;

String findid,p,q;

int n,i;

switch(choose1){

case 1:

System.out.printf("(1)全部查詢\n");

System.out.printf("(2)編號查詢\n");

System.out.printf("(3)價(jià)格查詢\n");

System.out.printf("請輸入相應(yīng)的序號進(jìn)行操作:");

choose2=a.nextInt();

if(choose2==1)print();

else if(choose2==2)

{

System.out.printf("請輸入進(jìn)行查詢的商品編號:");

Scanner c=new Scanner(System.in);

findid=c.nextLine();

? n=find(findid);

? if(n!=-1)

? System.out.printf("商品編號:"+goods[n].id+"\n商品名稱:"+goods[n].name+"\n商品價(jià)格:"+goods[n].price+"\n商品數(shù)量:"+goods[n].num+"\n");

? else System.out.printf("該商品編號不存在!\n");

}

else if(choose2==3){

Scanner d=new Scanner(System.in);

System.out.printf("請輸入相應(yīng)的價(jià)格:");

p=d.nextLine();

if(findp(p)==-1)System.out.printf("不存在該價(jià)格的商品信息!");

}

break;

case 2:addgoods();break;

case 3:

Scanner e=new Scanner(System.in);

System.out.printf("請輸入要刪除的商品編號:");

q=e.nextLine();

deletegoods(q);

System.out.printf("該商品已經(jīng)被刪除!\n");break;

case 4:System.out.printf("請輸入需要修改的商品的對應(yīng)編號:\n");

Scanner v=new Scanner(System.in);

change(v.nextLine());break;

}

}

//////////////////////////////////////////////////////////////////////////////////////

public static void main(String[] args) throws Exception{

SellSystem a=new SellSystem();

Scanner h=new Scanner(System.in);

int b;

while(true){

a.menu();

System.out.printf("輸入任意值返回主菜單,輸入0退出系統(tǒng)");

b=h.nextInt();

if(b==0)System.exit(0);

}

//System.out.printf(""+a.goods[0]);

}

}

//////////////////////////////////////////////////////////////////////////////////////////////

class Goods{

String id;

String name;

String price;

String num;

public Goods(String id,String name,String price,String num){

this.id=id;

this.name=name;

this.price=price;

this.num=num;

}

public Goods(){

this.id=null;

this.name=null;

this.price=null;

this.num=null;

}

}

附上部分效果圖

好吧,就這樣了,你自己測試一下吧,有問題可以聯(lián)系我QQ459384320

輸出你好用java語言編寫代碼怎么寫

你空前盯是問斗和悔中hello world嗎?

public Class MyClass {

public static void main() {

system.out.println("Hello World");

}

}

標(biāo)題名稱:java語言編寫代碼你好 java語言代碼大全及其含義
文章URL:http://chinadenli.net/article29/dsphjjh.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)外貿(mào)網(wǎng)站建設(shè)品牌網(wǎng)站設(shè)計(jì)Google移動網(wǎng)站建設(shè)靜態(tài)網(wǎng)站

廣告

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

網(wǎng)站托管運(yùn)營