JAVA编程 高手帮忙~

作者&投稿:全策 (若有异议请与网页底部的电邮联系)
请Java编程高手帮忙啊!!!~

楼主你好,这就是把一个集合的值循环输出到了某个table中,谢谢

package org.xxl.demo;import java.io.InputStream;import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class ProtectPrice { /** * @param args */ public static void main(String[] args) { System.out.println("*****************************************************"); System.out.println("请选择要购买的商品编号:"); List list = getProductDate() ; if(list!=null && list.size()>0){ for (Product product : list) { System.out.print(product.getNumber() + "、" + product.getName() + " "); } } System.out.println(); System.out.println("*****************************************************"); String flag = "" ; int productNumber = 0 , count = 0; Product product = null ; float tranAmt = 0 ; while(!flag.equals("n")){ productNumber = getProductNumber() ; switch (productNumber) { case 1: count = getProductCount() ; product = list.get(0) ; System.out.println(product.getName() + " ¥" + product.getPrice() + " 数量:" + count + " 合计:" + (float) product.getPrice()*count) ; tranAmt += (float) (product.getPrice()*count*0.8) ; break ; case 2: count = getProductCount() ; product = list.get(1) ; System.out.println(product.getName() + " ¥" + product.getPrice() + " 数量:" + count + " 合计:" + (float) product.getPrice()*count) ; tranAmt += (float) (product.getPrice()*count*0.8) ; break ; case 3: count = getProductCount() ; product = list.get(2) ; System.out.println(product.getName() + " ¥" + product.getPrice() + " 数量:" + count + " 合计:" + (float) product.getPrice()*count) ; tranAmt += (float) (product.getPrice()*count*0.8) ; break ; default: System.out.println("请输入正确的商品编号!!"); break; } flag = getFlag() ; if(flag.equals("n")){ System.out.println("折扣:0.8"); System.out.println("应付金额:"+tranAmt); System.out.print("实付金额:"); String amt = new Scanner(System.in).next() ; float amts = Float.valueOf(amt) - tranAmt ; while(amts getProductDate(){ List list = new ArrayList() ; Product p1 = new Product(1,"T 恤",245.0f) ; Product p2 = new Product(2,"网球鞋",570.0f) ; Product p3 = new Product(3,"网球拍",897.0f) ; list.add(p1) ; list.add(p2) ; list.add(p3) ; return list ; } }class Product{ int number ; String name ; float price ; public Product() { } public Product(int num,String name,float price){ this.number = num ; this.name = name ; this.price = price ; } public int getNumber() { return number; } public void setNumber(int number) { this.number = number; } public String getName() { return name; } public void setName(String name) { this.name = name; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; }}

3、
mian()
{
int g;
printf("Enter a mark: ");
scanf("%d",&g);
printf("g=%d : "g); /* g 中存放学生的成绩 */
switch (g/10)
{ case 10 :
case 9 : printf("A\n") break;
case 8 : pinrtf("B\n") break;
case 7 : printf("C\n") break;
default printf("D\n") break;
}
}

2.自己选择一个循环语句编程,求1~100的和。
mian()
{ int i,s;
s=1;
for(i=0; i<=100; i++)
s+=i
printf("s=%d\n",s);
}

你好强啊。

哥们,你看看书啊,书上很多这样的例子阿。

汗。。。。太简单了懒得编~!

这种简单问题也要请别人帮忙,还学编程干什么?


淮阴区17124187139: JAVA高手帮忙 -
满素舒威: 给你个小例子研究下: 不知道你学到什么程度,初学者研究方法的调用早了点,下面的看懂了再掺和其他方面的东东1.首先定义一个类:AccpTeacher public class AccpTeacher {//数据BEAN 定义2个字...

淮阴区17124187139: JAVA高手来帮帮忙啦,两道编程题.悬赏30分.在线等!!!编程题两道,编完回复前请验证下,我也会验证,验证正确分就是你的了.比较急!!!根据... -
满素舒威:[答案] 第一题: public class Complex { private double real;// 实部 private double imagin;// 虚部 // 重载默认构造方法 public Complex() { real = 0; imagin = 0; } // 有参构造方法 public Complex(double real, double imagin) { this.real = real; this.imagin = imagin...

淮阴区17124187139: Java编程 请高手帮忙 -
满素舒威: public class a{ public static void main(String args[]) { for(int i=1;i<=9;i++) { for(int j=1;j<=i;j++) { System.out.print(i+"*"+j+"="+i*j+" ...

淮阴区17124187139: java高手帮帮
满素舒威:public class TestMath { public static void main(String[] args) { int n = 20 ; double sum = 0; for(int i=1;i<=n;i++){ sum += Math.pow(2, i) - 1 ; } System.out.println("1+3+7+15+31+........+(2的20次方减1) = "+(int)sum); } }

淮阴区17124187139: 各位java高手帮忙哦 -
满素舒威: JAVA有JAVA SE,JAVA ME ,JAVA EE三个方向啊 JAVA SE 是开发桌面应用的,就目前来看,JAVA的桌面应用的很少.JAVA ME是手机嵌入式开发,开发手机相关应用,目前还算比较流行,慢慢的大多数手机都支...

淮阴区17124187139: JAVA高手来帮下忙
满素舒威: 必须使用x=(int) (x*0.2+0.5) 下面是一个测试例子 import java.io.*; public class Test{public int per_20(int num){return (int)(num*0.2+0.5) }public static void main(String [] args){System.out.println(per_20(5)); } } import java.io.*; public class Test{...

淮阴区17124187139: 求java高手帮忙解决一下 -
满素舒威: public class Pipei{ public static void main(String[] args) { String[] match={"computer","depart","our","goal"}; for(int i = 0; i <=...

淮阴区17124187139: 用Java编写程序题,高手来帮忙
满素舒威: 第一个: public static void main(String[] args){ String s = "sas"; int num = 0; for(int i=0;i<s.length();i++){ if(s.charAt(i)=='c'){ num ++; } } System.out.println("s中c出现的次数为"+num); } 第二个:输入的时候单词之间以1个空格分隔,输入完之后...

淮阴区17124187139: JAVA 编程基础,求大神高手帮忙解答,谢谢! -
满素舒威: System.out.println("本次活动特价商品有:"); System.out.println("NIKE背包"); System.out.println("..."); System.out.println("..."); 一样效果 非要定义的话 string a="NIKE背包";string b="ADIDAS";...System.out.println(a); 数组的话,String[] aa={a,b,c,d};

淮阴区17124187139: JAVA编程 高手帮忙~
满素舒威: 3、 mian() { int g; printf("Enter a mark: "); scanf("%d",&amp;g); printf("g=%d : "g); /* g 中存放学生的成绩 */ switch (g/10) { case 10 : case 9 : printf("A\n") break; case 8 : pinrtf("B\n") break; case 7 : printf("C\n") break; default printf("...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网