package s5;
public class test1 {
/*
* 计算蔬菜总价 为了丰富群众菜篮子,平抑菜价,相关部分组织了蔬菜的调运。 今某箱中有多个品种的蔬菜。
* 蔬菜的单价(元/公斤)存放在price数组中,
* 蔬菜的重量(公斤)存放在weight数组中。下面的代码计算该箱蔬菜的总价,试完善之。
* 把填空的答案(仅填空处的答案,不包括题面)存入考生文件夹下对应题号文件夹中的“解答.txt”中即可。
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double [] s1=new double[10];
double [] s2=new double[10];
for(int i=0; i<s1.length; i++)
{
s1[i]=1;
s2[i]=1;
}
System.out.println(getTotal(s1,s2));
}
public static double getTotal(double[] price, double[] weight)
{
double x = 0;
for(int i=0; i<price.length; i++)
{
x=x+price[i]*weight[i];
}
return x;
}
}
public class test1 {
/*
* 计算蔬菜总价 为了丰富群众菜篮子,平抑菜价,相关部分组织了蔬菜的调运。 今某箱中有多个品种的蔬菜。
* 蔬菜的单价(元/公斤)存放在price数组中,
* 蔬菜的重量(公斤)存放在weight数组中。下面的代码计算该箱蔬菜的总价,试完善之。
* 把填空的答案(仅填空处的答案,不包括题面)存入考生文件夹下对应题号文件夹中的“解答.txt”中即可。
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double [] s1=new double[10];
double [] s2=new double[10];
for(int i=0; i<s1.length; i++)
{
s1[i]=1;
s2[i]=1;
}
System.out.println(getTotal(s1,s2));
}
public static double getTotal(double[] price, double[] weight)
{
double x = 0;
for(int i=0; i<price.length; i++)
{
x=x+price[i]*weight[i];
}
return x;
}
}