⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 change.java

📁 电子商店
💻 JAVA
字号:
/**
 * 
 */
package product;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author 韦建艺 0658025
 * @2008.11.04
 * @
 */
public class Change {//KO!!!
  // Change product information
	// increase the price of “s” category by k%.
	public void Change(String str[][], double arr[][]) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = null;
		int a = 0;//price is increased by a%
		boolean valid0;
		valid0 = false;
		while (!valid0) {
		System.out.println("Input how much you want to increase the price");
		try {
			int anInt = Integer.parseInt(in.readLine());
			valid0=true;
			a = anInt;
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			System.out
			.println("Invalid Interger entered. Please try again.");
			//e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}
		}
		System.out
				.println("Input which product's price you want to change:computer,Software or Stereo");
		System.out.println("Cin C: computer");
		System.out.println("Cin S:  software");
		System.out.println("Cin O: stereo");
		try {
			String anString = in.readLine();
			s = anString;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		if (s.equals("C")) {
			for (int i = 0; i < str.length; i++) {
				if (str[i][0] == null) {
					break;
				} else {
					if (str[i][0].equals("computer")) {
						arr[i][0] = arr[i][0] * a*0.01;
						System.out.println("computer price is increased by " +a+"%");
						System.out.println();
					}
				}
			}
		} else if (s.equals("S")) {
			for (int i = 0; i < str.length; i++) {
				if (str[i][0] == null) {
					break;
				} else {
					if (str[i][0].equals("software")) {
						arr[i][0] = arr[i][0] * a*0.01;
						System.out.println("software price is increased by " +a+"%");
						System.out.println();
					}
				}
			}

		} else if (s.equals("O")) {
			for (int i = 0; i < str.length; i++) {
				if (str[i][0] == null) {
					break;
				} else {
					if (str[i][0].equals("stereo")) {
						arr[i][0] = arr[i][0] * a*0.01;
						System.out.println("stereo price is increased by " +a+"%");
						System.out.println();
					}
				}
			}

		} else {
			System.out.println("Can not find the product you want to remove!");
			System.out.println();

		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -