哎,我还是自己代码黏贴给你吧!免得总通不过!装不下这么多字,详情自己找我。 连接数据库类(添加修改会员信息) package com.to.java; import java.util.Scanner; import java.sql.*; public class Vds { Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); public void x(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); System.out.println("----------查询结果---------"); System.out.println(); System.out.println("会员号--密码"); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } con.close(); stmt.close(); }catch(Exception e){ System.out.println(e);} System.out.println("是否返回上级菜单"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("欢迎下次再次使用");System.exit(-1);}; break; }} public void j(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("请输入会员信息:"); System.out.println("请输入会员号:"); String f=input.next(); System.out.println("请输入密码:"); String q=input.next(); String sqlst="insert into gg values('"+f+"','"+q+"')"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上级菜单"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("欢迎下次再次使用");System.exit(-1);}; break; } } public void xg(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("请输入会员信息:"); System.out.println("请输入要修改的会员号:"); String f=input.next(); System.out.println("请输入修改的密码:"); String q=input.next(); String sqlst="update gg set mm='"+q+"' where id='"+f+"'"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上级菜单"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("欢迎下次再次使用");System.exit(-1);}; break; } } } package com.to.java; import java.util.Scanner; public class KeHu { Vds sj=new Vds(); public void kehu1(){ Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("******************************************************"+"\n\n"); System.out.println("1.显示所有客户信息"); System.out.println("2.添加客户信息"); System.out.println("3.修改客户信息"); System.out.println("4.查询客户信息"); System.out.println("5.返回上级菜单"); System.out.println("******************************************************"+"\n\n"); System.out.println("请输入数字:"); int a=Input.nextInt(); switch(a){ case 1: sj.x(); break; case 2: sj.j(); break; case 3: sj.xg(); break; case 4: sj.x();break; case 5: zhuck1.ZhucK1();break; } } } package com.to.java; public class GouWuXiTong { public static void main(String[] args){ ZhuCK zhuck=new ZhuCK(); zhuck.ZhucK(); } } package com.to.java; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Scanner; public class ZhuCK { Scanner Input=new Scanner(System.in); public void ZhucK(){ ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("\t\t"+"欢迎使用我心我素购物系统"); System.out.println("******************************************************"+"\n\n"); System.out.println("\t\t"+"1.登陆系统"); System.out.println(); System.out.println("\t\t"+"2.退出"+"\n\n"); System.out.println("******************************************************"); int d=1; while(d!=2){ System.out.println("请输入会员号:"); String p=Input.next(); System.out.println("请输入密码:"); String f=Input.next(); try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select * from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); if(id.equals(p)mm.equals(f)){ { System.out.println("请输入数字:"); int a=Input.nextInt(); switch(a){ case 1: zhuck1.ZhucK1(); break; case 2: break; }d=2; } } } }catch(Exception e){ System.out.println(e);} {System.out.println("输入错误请再次输入:");d=1;} } }} }
成都创新互联公司专注于荆门网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供荆门营销型网站建设,荆门网站制作、荆门网页设计、荆门网站官网定制、微信小程序定制开发服务,打造荆门网络公司原创品牌,更为您提供荆门网站排名全网营销落地服务。
使用结构体+数组,就可以 了
~
~
~
~
~~~~~~~~~~~~~~~~~~~~~~~~~
算是最简单的吧
package cn.job01;
import java.util.Scanner;
public class Lx07 {
public static void choice() {
System.out.println("登陆菜单 ");
System.out.println("1登陆系统");
System.out.println("2退出");
}
static void choice1() {
System.out.println("购物管理系统客户信息");
System.out.println("1显示所有客户信息");
System.out.println("2添加客户信息");
System.out.println("3修改客户信息");
System.out.println("4查询客户信息");
}
static void choice2() {
System.out.println("购物管理系统真情回馈");
System.out.println("1幸运大放送");
System.out.println("2幸运抽奖");
System.out.println("3生日问候");
}
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
System.out.println("请输入1or2");
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜单");
System.out.println("1客户信息管理");
System.out.println("2购物结算");
System.out.println("3真情回馈");
System.out.println("4注销");
break;
}
System.out.println("选择输入数字");
int num1 = input.nextInt();
switch (num1) {
case 1:
choice1();
break;
case 2:
System.out.println("购物结算");
break;
case 3:
choice2();
break;
case 4:
choice();
break;
}
}
}
package demo;
import java.util.Scanner;
public class practise {
public static void main(String[] args) {
System.out.println("**********");
System.out.println("1.客户信息管理");
System.out.println("2.购物结算");
System.out.println("3.真情回馈");
System.out.println("4.注销");
System.out.println("**********");
Scanner s = new Scanner(System.in);
System.out.println("请选择,输入数字:");
boolean isRight;
do{
isRight = true;
int choice = s.nextInt();
switch( choice ){
case 1:
System.out.println("执行客户信息管理");
isRight = false;
break;
case 2:
System.out.println("执行购物结算");
isRight = false;
break;
case 3:
System.out.println("执行真情回馈");
isRight = false;
break;
case 4:
System.out.println("注销");
isRight = false;
break;
default:
System.out.println("输入错误,请重新输入数字:");
}
}while(isRight == true);
System.out.println("程序结束!");
}
}
import java.util.Scanner;
//看这样的行吗?
public class StoreCharge {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("输入应付金额:");
double x = sc.nextDouble();
Price p1 = ampayable(x);
System.out.println(p1.toString());
System.out.println("输入实付金额:");
double y = sc.nextDouble();
Price p2 = ampaid(y);
System.out.println(p2.toString());
System.out.println("找零:"+charge(p1,p2).toString());
charge(p1,p2);
}
public static Price charge(Price p1,Price p2){//p1总货价 p2收款
int c,b;
if(p2.connerp1.conner){
b = p2.conner+10-p1.conner;
p2.element = p2.element-1;
}else
b = p2.conner-p1.conner;
c = p2.element - p1.element;
return new Price(c,b);
}
public static Price ampayable(double x){//应付金额
Price a = new Price();
a.element = (int)x;
a.conner = (int)(x*10 -((int)x)*10);
return a;
}
public static Price ampaid(double x){//实付金额
Price a = new Price();
a.element = (int)x;
a.conner = (int)(x*10 -((int)x)*10);
return a;
}
}
class Price{
int element;//元
int conner;//角
public Price(){}
public Price(int e,int c){
element = e;
conner = c;
}
public String toString(){
return element+"元"+conner+"角";
}
}
import java.util.Scanner;
import demo.ui.MainShell;
import demo.ui.PublicStatic;
public class DemoApp {
public static int getScanner() {
int input = 0;
try {
Scanner scanner = new Scanner(System.in);
input = scanner.nextInt();
} catch (Exception e) {
System.out.println("\t\t请重新输入");
return getScanner();
}
return input;
}
public static void main(String[] args) {
System.out.println("\t\t\t欢迎使用系统");
System.out.println("\t\t***********************");
System.out.println("\t\t\t1、客户信息管理");
System.out.println("\t\t\t2、购物结算");
System.out.println("\t\t\t3、真情回馈");
System.out.println("\t\t\t4、注销");
System.out.println("\t\t***********************");
while(true) {
int input = getScanner();
switch (input) {
case 1:
System.out.println("\t\t\t1、客户信息管理");
break;
case 2:
System.out.println("\t\t\t2、购物结算");
break;
case 3:
System.out.println("\t\t\t3、真情回馈");
break;
case 4:
System.out.println("\t\t\t4、注销");
break;
default:
System.out.println("\t\t请重新输入");
break;
}
if(input == 4) {
break;
}
}
}
}
当前标题:java购物结算的代码 java购物结算的代码怎么用
网站链接:https://www.cdcxhl.com/article14/docidge.html
成都网站建设公司_创新互联,为您提供品牌网站设计、网站策划、定制网站、虚拟主机、App开发、静态网站
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联