成都创新互联网站制作重庆分公司

会员积分java代码 积分代码实现

急!Java 练习 根据会员积分,计算所享受的折扣。

package com.javaeye.morflame;

创新互联公司专注于襄州网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供襄州营销型网站建设,襄州网站制作、襄州网页设计、襄州网站官网定制、重庆小程序开发服务,打造襄州网络公司原创品牌,更为您提供襄州网站排名全网营销落地服务。

import java.util.Scanner;

public class Test {

public static void main(String[] args) {

Scanner in=new Scanner(System.in);

System.out.print("输入积分:");

int a=in.nextInt();

int result=zhekou(a);

System.out.println("折扣为"+result+"折");

}

//求折扣的函数

private static int zhekou(int a) {

int result=0;

if(a2000)

{

result= 9;

}

else if(a4000){

result= 8;

}

else if(a8000){

result= 7;

}

else if(a=8000){

result= 6;

}

else{

System.out.println("输入的积分不在范围内!");

}

return result;

}

}

如果楼主觉得还不行,自己在这个基础上改一下下代码肯定就OK了

JAVA 大家帮忙看一下怎么做 会员积分x x

Java程序:

import java.util.Scanner;

public class xll {

public static void main(String[] args) {

int score;

double count = 1.0;

Scanner input = new Scanner(System.in);

System.out.println("请输入会员积分:");

score = input.nextInt();

if(score 2000)

count = 0.9;

else if(score 4000)

count = 0.8;

else if(score 8000)

count = 0.7;

System.out.println("该会员享受的折扣是:");

System.out.println(count + "折");

}

}

运行测试:

请输入会员积分:

5000

该会员享受的折扣是:

0.7折

请输入会员积分:

3420

该会员享受的折扣是:

0.8折

有一问题,如果积分超过8000是几折?

java输入会员编号和会员积分,编号相同则停止输入让后输出的所有会员编号和积

public static void main(String args[]) {

//声明一个存放会员信息的list集合,会员信息由编号和积分组成一个map

ArrayListMapObject, String list = new ArrayListMapObject, String();

boolean flag=false;//没有找到相同的会员编号

while(1==1){

Scanner scan = new Scanner(System.in);

System.out.println("请输入会员编号:");

String bh = scan.nextLine();

System.out.println("请输入会员积分:");

String jf = scan.nextLine();

if(list!=null list.size()0){

for (int i = 0; i list.size(); i++) {//循环存放历史输入会员信息的集合

MapObject, String m = list.get(i);

if(bh.equals(m.get("bh"))){//将当前输入的会员编号和已输入的相同时

flag=true;//已找到

}

}

}

if (flag==true) {//已找到

System.out.println("所有输入的会员信息如下:");

for (int i = 0; i list.size(); i++) {//输出所有的会员信息

MapObject, String m = list.get(i);

System.out.println("会员编号:"+m.get("bh")+"-----会员积分:"+m.get("jf")+"");

}

//结束循环输入

break;

}else{//没有找到相同信息时,存放进list集合

MapObject, String map = new HashMapObject, String();

map.put("bh", bh);

map.put("jf", jf);

list.add(map);//将输入的会员信息存放入list

}

}

}

急!Java 练习 根据会员积分,计算所享受的折扣.

import java.util.Scanner;

public class Test1 {

public static void main(String[] args) {

System.out.println("请输入会员积分:");

Scanner sc=new Scanner(System.in);

int a=sc.nextInt();

sc.close();

if(a200){

System.out.println("该会员享受的折扣是:0.9");

}else if(a=2000a=4000){

System.out.println("该会员享受的折扣是:0.8");

}else if(a=4000a=8000){

System.out.println("该会员享受的折扣是:0.7");

}else if(a=8000){

System.out.println("该会员享受的折扣是:0.6");

}

}

}

求Accp6.0java第十四章练习题一二的代码!

我自己写的,运行没问题,如果有小问题,欢迎指出

练习一:

Customer类:

package com.wxws.sms;

public class Customer {

/**

* @param args

*/

String CustNumber;

int CustPoint;

}

--------------------------------分隔符------------------------------------

CustManager类:

package com.wxws.sms;

import java.util.*;

public class CustManager {

Customer customers[]=new Customer[100];

public void CustAdd(Customer cust) {

// TODO Auto-generated constructor stub

for(int i=0;icustomers.length;i++){

if(customers[i]==null){

customers[i]=cust;

break;

}

}

}

public void showCustomer(){

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

System.out.println("number\tpoint");

for(int i=0;icustomers.length;i++){

if(customers[i]!=null){

System.out.println(customers[i].CustNumber+"\t"+customers[i].CustPoint);

}

}

}

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

Customer run=new Customer();

CustManager move=new CustManager();

@SuppressWarnings("resource")

Scanner input=new Scanner(System.in);

System.out.print("Please input your Vip number:");

run.CustNumber=input.next();

System.out.print("Please input your Vip point:");

run.CustPoint=input.nextInt();

move.CustAdd(run);

move.showCustomer();

}

}

---------------------------------------------分割符号---------------------------------------------------

练习二(将Customer类的属性改成数组):

package com.wxws.sms;

public class Customer {

/**

* @param args

*/

String CustNumber[]=new String[100];

int CustPoint[]=new int[100];

}

---------------------------------------------分割符号---------------------------------------------------

package com.wxws.sms;

import java.util.*;

public class CustManager {

Customer customers[]=new Customer[100];

public void CustAdd(Customer cust) {

// TODO Auto-generated constructor stub

for(int i=0;icustomers.length;i++){

if(customers[i]==null){

customers[i]=cust;

break;

}

}

}

public void showCustomer(){

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

System.out.println("number\tpoint");

for(int i=0;icustomers.length;i++){

if(customers[i]!=null){

System.out.println(customers[i].CustNumber[i]+"\t"+customers[i].CustPoint[i]);

}

}

}

public int searchScore(String custNo){

int point=1;

for(int i=0;icustomers.length;i++){

if(customers[i]!=null){

if((customers[i].CustNumber[i]).equals(custNo)){

System.out.println("The number of Vip's point is:"+customers[i].CustPoint[i]);

point=customers[i].CustPoint[i];

}

}

}

return point;

}

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

Customer run=new Customer();

CustManager move=new CustManager();

@SuppressWarnings("resource")

Scanner input=new Scanner(System.in);

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

System.out.print("Please input your Vip number:");

run.CustNumber[i]=input.next();

System.out.print("Please input your Vip point:");

run.CustPoint[i]=input.nextInt();

move.CustAdd(run);

}

move.showCustomer();

System.out.print("Please input the Vip number you want to check:");

String custNum=input.next();

move.searchScore(custNum);

}

}

java 循环输入多个会员信息 怎样根据会员编号查找会员积分?

import java.util.ArrayList;

import java.util.List;

public class Test {

public static void main(String[] args) {

ListUser userList = new ArrayListUser();

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

userList.add(new User(String.valueOf(i),i));

}

//查找会员编号为3的积分

for(User u : userList) {

if("3".equals(u.getId().toString())) {

System.out.println("编号"+u.getId()+"会员的积分为:"+u.getPoint());

}

}

}

}

class  User {

private String id;//会员编号

private int point;//积分

public User(String id,int point) {

this.id = id;

this.point = point;

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public int getPoint() {

return point;

}

public void setPoint(int point) {

this.point = point;

}

}


网页标题:会员积分java代码 积分代码实现
文章源于:http://cxhlcq.com/article/hjhjgg.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部