JavaInventory.zip

  • tiche
    了解作者
  • Visual C++
    开发工具
  • 39KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 1
    下载次数
  • 2017-10-01 23:47
    上传日期
other D-ITG 2.6 IT IS A BEST SOFTWAR FOR GENERATIG THE TRAFFIC thenka
JavaInventory.zip
  • JavaInventory
  • bin
  • javaInventory
  • DVD.class
    1.8KB
  • ProductPart5.class
    2.1KB
  • ProductTester2.class
    1.9KB
  • ProductPart2.class
    1.9KB
  • ProductTester3.class
    2KB
  • ProductTester4.class
    2.6KB
  • ProductTester1.class
    997B
  • ProductPart1.class
    1.8KB
  • ProductPart4.class
    2.1KB
  • ProductPart3.class
    1.9KB
  • ProductTester5.class
    2KB
  • .settings
  • org.eclipse.jdt.core.prefs
    598B
  • src
  • javaInventory
  • DVD.class
    1.9KB
  • DVD.java
    1.6KB
  • ProductPart5.class
    2.5KB
  • ProductPart5.java
    2.4KB
  • ProductTester2.class
    1.8KB
  • ProductTester5.java
    1.6KB
  • ProductPart2.class
    1.9KB
  • ProductTester3.class
    1.9KB
  • ProductTester4.class
    2.6KB
  • ProductPart4.java
    2.5KB
  • ProductTester1.java
    1.1KB
  • ProductTester2.java
    2.2KB
  • ProductTester1.class
    941B
  • ProductTester.class
    4.6KB
  • ProductPart1.class
    1.8KB
  • ProductTester3.java
    1.8KB
  • ProductPart4.class
    2.1KB
  • ProductPart3.java
    2.3KB
  • ProductPart3.class
    1.9KB
  • ProductPart2.java
    2.2KB
  • ProductTester4.java
    3.3KB
  • ProductTester5.class
    2.1KB
  • ProductPart1.java
    2KB
  • .classpath
    301B
  • .project
    389B
内容介绍
/** * @author Joshua Gural * Trinity High School, Washington, PA * This class was designed and written for * the Oracle Academy Java Fundamentals Course * * @version 1.00 2012/3/29 */ package javaInventory; import java.util.Scanner; //imports the Scanner class for keyboard input public class ProductTester4 { public static void main(String[] args) { //this section is the same as ProductTester 3, which allows the user to create products //************************************************************************************ Scanner s = new Scanner(System.in); //create a Scanner object for keyboard input System.out.println("Hello User, let's add products to the inventory"); System.out.println("Enter the number of products you would like to add."); System.out.println("Enter 0 (zero) if you do not wish to add products."); int numproducts = s.nextInt(); //assume that the user enters a valid integer value if(numproducts==0){ System.out.println("\n\nThank you, no products were entered"); } else{ ProductPart4[] p = new ProductPart4[numproducts]; for(int i = 0; i < numproducts; i++){ System.out.println("\n\nEntering item #" + i); System.out.println("\nPlease enter the item number"); int id = s.nextInt(); System.out.println("Please enter the product name"); String name = s.next(); System.out.println("Please enter the number in stock for this product"); int qty = s.nextInt(); System.out.println("Please enter the price for this product"); double price = s.nextDouble(); p[i] = new ProductPart4(id, name, qty, price); } //each item entered above is displayed one at a time and then //the following loop allows the user to add a quantity to a product //OR deduct a quantity from a prodct for(int i = 0; i < numproducts; i++){ System.out.println("*****************************************"); System.out.println(p[i]); //displays the product System.out.println("\nWould you like to modify this item?"); System.out.println("Enter 1 to add inventory, 2 to deduct, or 3 for neither"); int ans = s.nextInt(); int qty = 0; if(ans==1){ //add to the product's quantity in stock System.out.println("\nHow many would you like to add?"); qty = s.nextInt(); p[i].addToInventory(qty); System.out.println("\nNew information for " + p[i].getName()); System.out.println(p[i]); //display the product again } else if(ans==2){ //deduct from the product's quantity in stock System.out.println("How many would you like to deduct?"); qty = s.nextInt(); p[i].deductFromInventory(qty); System.out.println("\nNew information for " + p[i].getName()); System.out.println(p[i]); //display the product again } //no need to handle ans==3, which would do nothing } //Display the array again System.out.println("\n\nFinal inventory list:"); for(int i = 0; i < numproducts; i++){ System.out.println(p[i]); } } } }
评论
    相关推荐
    • Boost.Asio C++ Network Programming.zip
      Boost.Asio C++ Network Programming
    • c++references.rar
      这是c++学习的权威书籍,里面讲解的很详细,适合初学者学习
    • c++primer程序.rar
      这本久负盛名的 C++经典教程,时隔八年之久,终迎来史无前例的重大升级。除令全球无数程序员从中受益,甚至为之迷醉的——C++ 大师 Stanley B. Lippman 的丰富实践经验,C++标准委员会原负责人 Josée Lajoie 对C++...
    • C++ Primer.rar
      很经典的一本C++的书,适合学习过C++的人. 可以学到很多,处理方法.
    • C++.FAQs.Second.Edition
      C++.FAQs.Second.Edition 免费下载,欢迎下载
    • C++编程规范.rar
      编程规范(101条规则、准则与最佳实践,英文)获图灵奖书籍,包括chm、pdf版本
    • C++.Primer.3rd.En
      很好的C++资料,希望对大家有帮助。
    • C++解析JSON.rar
      C++解析JSON文件,包含jsoncpp-src-0.6.0-rc2和rapidjson两个。
    • Thinking in C++英文版.rar
      Thinking in C++英文版 Thinking in C++英文版 Thinking in C++英文版
    • cJSON C++ json解析.rar
      cJSON是一个仅有一个.h文件,一个.c文件组成的JSON解析器,它是由纯C(ANSI C89)实现的,跨平台性较好。cJSON是采用链表存储的。 cJSON库在使用的时候只需要如下两步:将cJSON.c(或者库文件)和cJSON.h添加到项目中...