package?cn.javass.spring3.hello.java;
我們提供的服務有:網站制作、成都網站建設、微信公眾號開發(fā)、網站優(yōu)化、網站認證、云溪ssl等。為上千家企事業(yè)單位解決了網站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的云溪網站制作公司
public?class?Test2?{
public?static?void?main(String[]?args)?{
int?bank?=?10000;
int?count?=?0;
while?(bank?=?20000)?{
bank?+=?bank?*?6.25?*?0.01;
count++;
}
System.out.println(count);
}
}
結果12年
我試試吧?你留個QQ啥的??做完了好給你啊
看了一會題?感覺答案就是x1=0,x2=0,x3=110000
x3的價格跟成功率都是最多了?所以只賣x3就行了
還用算嗎
public?class?ForMax?{
/**
?*?@param?args
?*/
public?static?void?main(String[]?args)?{
//?TODO?Auto-generated?method?stub
//為了簡化程序,也為了避免計算出來的數量中包含小數,所以數量這里除以1000,成功率都乘以1000
int?x1=0,x2=0,x3=0;
double?a1=6;
double?a2=7;
double?a3=3;
int?b1=10,b2=20,b3=30;
double?money=0;
double?max=0;
for?(int?i?=?0;?i?=?110;?i++)?{
for?(int?j?=?0;?j?=?110;?j++)?{
for?(int?k?=?0;?k?=?110;?k++)?{
if?(i+j+k==110)?{
if?(i*a1+j*a2+k*a3=500)?{
money=i*a1*b1+j*a2*b2+k*a3*b3;
if?(moneymax)?{
max=money;
x1=i*1000;
x2=j*1000;
x3=k*1000;
}
}
}
}
}
}
System.out.println("最高收益為:"+max);
System.out.println("x1:"+x1);
System.out.println("x2:"+x2);
System.out.println("x3:"+x3);
}
}
代碼給你了 你自己設計成功率吧,0.3的結果是只賣x2
老板,有用的話別忘采納和點贊喲,給我個小小支持。
先上代碼:
public static void main(String[] args) {
int result = 0;
Scanner scanner = new Scanner(System.in);
System.out.println("請輸入要統計的字符竄:");
String str = scanner.nextLine();
System.out.println("input:"+str);
String arrays[] = str.split(" ");
for (int i = 0; i arrays.length; i++) {
if (!arrays[i].contains("-")) {
result += getNumbers(arrays[i]);
}else {
result -= getNumbers(arrays[i]);
}
}
System.out.println("output:"+result);
}
//截取數字
public static int getNumbers(String content) {
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
return Integer.parseInt(matcher.group(0));
}
return 0;
}
運行效果:
public?class?Product?{
private?String?productName;
private?double?costPrice;
private?double?price;
private?java.util.Date?outDate;
private?String?batch;
public?String?getProductName()?{
return?productName;
}
public?void?setProductName(String?productName)?{
this.productName?=?productName;
}
public?double?getCostPrice()?{
return?costPrice;
}
public?void?setCostPrice(double?costPrice)?{
this.costPrice?=?costPrice;
}
public?double?getPrice()?{
return?price;
}
public?void?setPrice(double?price)?{
this.price?=?price;
}
public?java.util.Date?getOutDate()?{
return?outDate;
}
public?void?setOutDate(java.util.Date?outDate)?{
this.outDate?=?outDate;
}
public?String?getBatch()?{
return?batch;
}
public?void?setBatch(String?batch)?{
this.batch?=?batch;
}
/**
?*?判斷產品是否過期
?*?@param?product
?*?@return?是否過期
?*?@returnType?boolean
?*/
public?boolean?isOutDate(Product?product){
return?new?java.util.Date().getTime()??product.getOutDate().getTime();
}
/**
?*?計算毛利潤
?*?@param?product
?*?@return?毛利潤
?*?@returnType?double
?*/
public?double?getGrossProfit(Product?product){
return?product.getPrice()?-?product.getCostPrice();
}
/**
?*?修改產品價格
?*?@param?product
?*?@param?price
?*/
public?void?updateProductPrice(Product?product,?double?price){
product.setPrice(price);
}
/**
?*?打折出售
?*?@param?product
?*?@param?price
?*/
public?void?discount(Product?product,?double?discount){
product.setPrice(product.getPrice()?*?discount);
}
}
public?class?Demo2?{
public?static?void?main(String[]?args)?{
double?price?=?100.0?;//單價
int?nums?=?200;//數量
double?total;//總價
total?=???price*nums;//?計算總價
double?profit?;//利潤
double?cost=12000;//成本
double?tax=0.17;//稅率
profit?=?(total-cost)*(1-tax);?//計算利潤
System.out.println("利潤:"+profit+"元");//輸出利潤
}
}
運行測試
利潤:6640.0元