需要帮助Class Project! [英] Need help with Class Project!

查看:44
本文介绍了需要帮助Class Project!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我对Java编程很陌生,到目前为止我已经能够匆匆忙忙了,但是我完全坚持这个任务。这是本周到期的作业 -

?修改库存程序,以便应用程序可以处理多个项目。使用数组存储项目。输出应一次显示一个产品的信息,包括产品编号,产品名称,库存单位数量,每个单位的价格以及该产品的库存价值。此外,输出应显示整个库存的价值。


?创建一种方法来计算整个库存的价值。


?创建另一种方法,按产品名称对数组项进行排序。不要使用array.sort。


编译并运行Java程序。


这是我上周的代码 -

展开 | 选择 | Wrap | 行号

解决方案


好​​的,所以我对Java编程很陌生,到目前为止我已经能够匆匆忙忙了,但是我完全坚持这个任务。这是本周到期的作业 -

?修改库存程序,以便应用程序可以处理多个项目。使用数组存储项目。输出应一次显示一个产品的信息,包括产品编号,产品名称,库存单位数量,每个单位的价格以及该产品的库存价值。此外,输出应显示整个库存的价值。


?创建一种方法来计算整个库存的价值。


?创建另一种方法,按产品名称对数组项进行排序。不要使用array.sort。


编译并运行Java程序。


这是我上周的代码 - < br $>
//库存计划第1部分


类库存


{

私有字符串名称; //商店DVD名称

private long itemNumber; //商店商品编号

私人长库存数量; //库存quanity

private double dvdPrice; //商店DVD价格

公共库存()


{

名称="" ;;

itemNumber = 0L;

stockQuantity = 0L;

dvdPrice = 0.0;

}

公共库存(String Name,long itemNumber,long stockQuantity,double dvdPrice)

{

this.Name = Name;

this.itemNumber = itemNumber;

this.stockQuantity = stockQuantity;

this.dvdPrice = dvdPrice;

}



public void setItemName(String Name)//设置和获取项目名称的方法

{

this.Name = Name;

}

public String getItemName()

{

返回名称;

}



public void setItemNumber(long itemNumber)//设置和获取项目编号的方法

{

itemNumber = itemNumber;

}
公共长度getItemNumber()

{

返回itemNumber;

}



public void setStockQuantity(长数量)//设置和获取库存数量的方法

{

stockQuantity = stockQuantity;

}

public long getStockQuantity()

{

return stockQuantity;

}



public void setItemPrice(double dvdPrice)//设置和获取商品价格的方法

{

this.dvdPrice = dvdPrice;

}

public double getItemPrice()

{

return dvdPrice;

}


public double calculateInventoryValue()//计算库存库存价值的方法

{

返回dvdPrice * stockQuantity;

}


} //结束类库存



公共类库存1


{


public static void main(String args [])

{


库存p =新库存(24:第4季,1,10,24.99); //列出第一张DVD库存信息

System.out.println();

System.out.print(" DVD电影库存:"); //显示标题

System.out.printf(" \ n\\\
DVD Title:%s \ n",p.getItemName()); //显示DVD标题

System.out.printf(" Item Number:%s \ n",p.getItemNumber()); //显示项目编号

System.out.printf("库存中的数量:%s \ n,p.getStockQuantity()); //显示库存数量

System.out.printf(" Item Price:


%。2f\ n,p.getItemPrice()) ; //显示DVD价格

System.out.printf("库存值:


%。2f\ n,p.calculateInventoryValue()); //显示商品库存的总价值

System.out.println();

System.out.println();


}

} //结束课库存1


有人可以帮助我进入下一步!提前谢谢了!! :)



您下次发布代码时请记得使用代码标签。现在针对您的问题,请阅读并发布,如果您仍需要任何帮助。


OK, so I''m very new to Java programming and I''ve been able to squeek by so far, but I''m completely stuck on this assignment. Here is the assignment that is due this week -
? Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the output should display the value of the entire inventory.

? Create a method to calculate the value of the entire inventory.

? Create another method to sort the array items by the name of the product. DON''T use array.sort.

Compile and run the Java program.

And here is my code from last week -

Expand|Select|Wrap|Line Numbers

解决方案

OK, so I''m very new to Java programming and I''ve been able to squeek by so far, but I''m completely stuck on this assignment. Here is the assignment that is due this week -
? Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the output should display the value of the entire inventory.

? Create a method to calculate the value of the entire inventory.

? Create another method to sort the array items by the name of the product. DON''T use array.sort.

Compile and run the Java program.

And here is my code from last week -

//Inventory Program Part 1


class Inventory

{
private String Name; //stores DVD name
private long itemNumber; //stores item number
private long stockQuantity; //stores quanity in stock
private double dvdPrice; //stores DVD price
public Inventory ()

{
Name = "";
itemNumber = 0L;
stockQuantity = 0L;
dvdPrice = 0.0;
}
public Inventory (String Name, long itemNumber, long stockQuantity, double dvdPrice)
{
this.Name = Name;
this.itemNumber = itemNumber;
this.stockQuantity = stockQuantity;
this.dvdPrice = dvdPrice;
}


public void setItemName(String Name) //Method to set and get the item name
{
this.Name = Name;
}
public String getItemName()
{
return Name;
}


public void setItemNumber(long itemNumber) //Method to set and get the item number
{
itemNumber = itemNumber;
}
public long getItemNumber()
{
return itemNumber;
}


public void setStockQuantity(long quantity) //Method to set and get the quantity in stock
{
stockQuantity = stockQuantity;
}
public long getStockQuantity()
{
return stockQuantity;
}


public void setItemPrice(double dvdPrice) //Method to set and get the item price
{
this.dvdPrice = dvdPrice;
}
public double getItemPrice()
{
return dvdPrice;
}


public double calculateInventoryValue() //Method to calculate the value of the in stock inventory
{
return dvdPrice * stockQuantity;
}

}//end class Inventory


public class Inventory1


{

public static void main( String args[])
{

Inventory p = new Inventory("24: Season 4", 1, 10, 24.99); //Lists 1st DVD inventory information
System.out.println();
System.out.print( "Inventory of DVD Movies: " ); //display title
System.out.printf("\n\nDVD Title: %s\n",p.getItemName()); //display DVD title
System.out.printf("Item Number: %s\n",p.getItemNumber()); //display item number
System.out.printf("Quantity in Stock: %s\n",p.getStockQuantity()); //display quantity in stock
System.out.printf("Item Price:


%.2f\n",p.getItemPrice()); //display DVD price
System.out.printf("Inventory Value:


%.2f\n",p.calculateInventoryValue()); //display total value of inventory for item
System.out.println();
System.out.println();

}
}//end class Inventory1


Can somebody please help me get to the next step!! Many thanks in advance!! :)

Hi next time you post code please remember to use code tags. Now for your problem please read this and post if you still need any help.


这篇关于需要帮助Class Project!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆