public class App {
public static void main(String[] args) {
MyBusiness mb = new MyBusiness();
mbsetInventoryName("Iphone");
mbsetInventoryUnits(1000);
mbaddInventoryUnit(500);
mblessInventory(800);
Systemoutprintln(mbgetInventoryDescription()+",库存:"+mbgetIventoryTotal());
}
}
class MyBusiness {
private int inventoryUnits;
private int iventoryTotal;
private String inventoryName;
public int getInventoryUnits() {
return inventoryUnits;
}
public void setInventoryUnits(int inventoryUnits) {
thisinventoryUnits = inventoryUnits;
thisiventoryTotal = inventoryUnits;
}
public String getInventoryDescription() {
return inventoryName;
}
public void setInventoryName(String inventoryName) {
thisinventoryName = inventoryName;
}
public int getIventoryTotal() {
return iventoryTotal;
}
public void addInventoryUnit(int totalInvetoryUnits){
if(totalInvetoryUnits <= 0){
Systemoutprintln("数量错误");
return;
}
iventoryTotal += totalInvetoryUnits;
}
public void lessInventory(int totalInventoryUnits){
if(totalInventoryUnits <= 0){
Systemoutprintln("数量错误");
return;
}
if(iventoryTotal >= totalInventoryUnits){
iventoryTotal -= totalInventoryUnits;
}else{
Systemoutprintln("库存不够");
}
}
}
import javautilScanner;
public class 美元
{
private static Scanner sc=new Scanner(Systemin);
public static void main(String[] args)
{
Systemoutprintln("\n\t\t==========提示:1美元=100美分=========\n");
Systemoutprintln("请输入钱数美元为单位,自动转换成美分!");
while(true)
init(scnextInt());
}//初始化!
private static void init(int n)
{
int x=n100,i=0;
for (int a=1;a<x ;a+=25 )
{
for (int b=1;b<x ;b+=10 )
{
for (int c=1; c<x;c+=5 )
{
for (int d=1;d<x ;d++ )
{
if((a25+b10+c5+d)==x)
{
i++;
Systemoutprint("25美分==>"+a+"\t10美分==>"+b+"\t5美分==>"+c+"\t1美分==>"+d+"\n");
}
}
}
}
}
Systemoutprintln("\n你输入的是:"+n+"美元==>"+x+"美分\t一共可以有"+i+"种可能!\n\n继续测试:");
}
}
以上就是关于求一个java程序,请大神详细指教.全部的内容,包括:求一个java程序,请大神详细指教.、用java编写个程序,确定存钱罐里的硬币总面值并以美元和美分为单位输出钱数。、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)