资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

支付结算java代码 java购物结算代码

Java购物结算,卡在不懂do...while跳出循环和最后的总金额。求解决,谢谢

刚帮你调测了一下,当你输入"n"的时候,已经跳出循环了,只不过你没有输出提示,以为没出来,

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、小程序设计、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了彰武免费建站欢迎大家使用!

又输入字符了所有报错了,应该是输入金额的,我帮你加了下输出你可以看下结果;

public static void main(String args[]){

System.out.println("********************");

System.out.println("");

System.out.println("请选择购买商品编号:");

System.out.println("1.T恤(¥245.0) 网球鞋(¥570.0) 网球拍(¥500.0)");

System.out.println("********************");

System.out.println("");

double s=0;

String d;

do{

System.out.println("请输入商品编号:");

Scanner input=new Scanner(System.in);

int a=input.nextInt();

if(a==1){

System.out.println("请输入购买数量:");

int b=input.nextInt();

double c=245*b;

System.out.println("T恤¥245.0 数量:"+b+" "+"合计:"+c);

s=s+c;

}

else if(a==2){

System.out.println("请输入购买数量:");

int b=input.nextInt();

double c=570*b;

System.out.println("网球鞋¥245.0 数量:"+b+" "+"合计:"+c);

s=s+c;

}

else if(a==3){

System.out.println("请输入购买数量:");

int b=input.nextInt();

double c=500*b;

System.out.println("网球拍¥245.0 数量:"+b+" "+"合计:"+c);

s=s+c;

}

else {System.out.println("无此商品");}

System.out.println("否继续(y/n)");

d=input.next();

}while(d.equals("y"));

System.out.println("===========付款===========");

System.out.println("=====输入金额=====");

Scanner input=new Scanner(System.in);

int x=input.nextInt();

double m=s*0.8;

System.out.println("折扣:0.8");

System.out.println("应付金额:"+m);

System.out.println("实际金额:"+x);

double p=x-m;

System.out.println("找钱:"+p);

}

java编写一个网上支付系统界面

html

head

meta http-equiv="Content-Type" content="text/html; charset=utf-8"

title购物与结算/title

style type="text/css"

/style

link rel="stylesheet" href="

script src="

script src="

script src="

script src="

(beta4)/IE9.js"/script

script src=" 

script type="text/javascript"

function pay()

{

var link = document.getElementById("a1");

link.click();

var a = new Array();

a[0]="html教程";

a[1]=12;

a[2]=1;

a[3]=a[1]*a[2];

var a1 = new Array();

a1[0]="java详解";

a1[1]=25;

a1[2]=2;

a1[3]=a1[1]*a1[2];

var b = new Array();

b[0]=a;

b[1]=a1;

var amount =0;

for(var i=0;ib.length;i++)

{

var c = new Array();

c=b[i];

amount = amount+c[3];

var tr ="tr";

for(var j=0;jc.length;j++)

{

tr+="td"+c[j]+"/td";

}

tr+="/tr";

$("#list").append(tr);

$("#all").html("b总计:/bfont color=\"red\""+amount+"/font")

}

}

function goon()

{

var link = document.getElementById("a2");

link.click();

$("#news").html("支付成功!!");

}

/script

/head

body

input type="button" class="btn btn-danger" value="点击结算" onclick="pay()"

a href="#myModaltishi" role="button" class="btn" data-toggle="modal" id="a1" style="display: none"/a 

div id="myModaltishi" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"  

div class="modal-header"  

button type="button" class="close" data-dismiss="modal" aria-hidden="true"×/button  

h3 id="myModalLabel"购物车/h3  

/div  

div class="modal-body"  

div

table id="list" style="width: 95%;" class="table"

th商品名称/th

th单价/th

th数量/th

th金额/th

/table

/div

div align="right" id="all"/div

/div  

div class="modal-footer"  

button class="btn" data-dismiss="modal" aria-hidden="true"继续挑选/button  

button class="btn btn-primary" data-dismiss="modal" onclick="goon()"支付/button  

/div  

/div 

a href="#myModaltishi1" role="button" class="btn" data-toggle="modal" id="a2" style="display: none"/a 

div id="myModaltishi1" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"  

div class="modal-header"  

button type="button" class="close" data-dismiss="modal" aria-hidden="true"×/button  

h3 id="myModalLabel"系统提示/h3  

/div  

div class="modal-body"  

h3 id="news" align="center"/h3

/div  

div class="modal-footer"  

button class="btn btn-primary" data-dismiss="modal"知道了/button  

/div  

/div 

/body

!-- 浏览器打开可查看效果,

另外由于页面使用了bootstrap框架建议使用渲染较高的浏览器,例如:火狐 --

/html

编写java代码要求顾客输入购买多少斤当用户输入为10斤以内,则输出用户应支付金额?

2、public class Test11 {

public static void main(String[] args) {

System.out.println("滞贸旅客的人数" + (1189 - 108*10) );

}

}

3、public class Test11 {

public static void main(String[] args) {

try {

Scanner scanner = new Scanner(System.in);

System.out.print("输入购买鸡蛋(斤):");

int number = scanner.nextInt();

if(number10){

throw new RuntimeException("不允许购买这么多!");

}

else {

System.out.println("用户应支付金额"+number*3.98);

}

}

catch (Exception e){

System.out.println(e.getMessage());

}

}

}

java编写程序:要求用户输入贷款的年利率,总金额和年数,程序计算月支付金额和

你也不说计算公式,不知道怎么计算,我去网上找了一个月支付款的计算公式,不知道和你题目的要求是否一样,如果不一样你就改下公式就行。

java代码如下:

public class Loan {

public static void main(String[] args){

double rate ;//利率

int year ; //年数

double money ; //贷款总额

double monthpay ;//月付款

Scanner sc = new Scanner(System.in);

System.out.println("输入月利率:");

rate = sc.nextDouble();

System.out.println("输入年数:");

year = sc.nextInt();

System.out.println("输入贷款总额:");

money = sc.nextDouble();

//计算月付款

monthpay = (money * rate)/Math.abs(1 - (1 / (1 + rate ) * year * 12 ));

System.out.println("每月应该还贷款:" + monthpay);

}

}


网站栏目:支付结算java代码 java购物结算代码
当前网址:http://cdkjz.cn/article/hjschi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220