can you fix this out. I don't know where i have done
mistake.
package exampro;
public class Exampro {
public static void main(String[] args)
{
// TODO Auto-generated method
stub
Scanner sc= new
Scanner(System.in);
double[]
litres_of_diesel_filled=new double[5];
double[] cost_of_each_litre
=new double[5];
double[]
distance_travelled=new double[5];
double total_cost=0;
double
total_litres_consumed=0;
double
total_distance=0;
for(int i=0;i<5;i++)
{
System.out.println("Enter the
amount of diesel filled for filling "+(i+1)+" :");
litres_of_diesel_filled=sc.nextDouble();
System.out.println("Enter the
cost of one litre of diesel for filling "+(i+1)+" :");
cost_of_each_litre=sc.nextDouble();
System.out.println("Enter the
distance travelled for filling "+(i+1)+" :");
distance_travelled=sc.nextDouble();
total_distance=total_distance+distance_travelled;
total_litres_consumed=total_litres_consumed+litres_of_diesel_filled;
total_cost=total_cost+(cost_of_each_litre*litres_of_diesel_filled);
}
double
average_diesel_consumption=total_litres_consumed/total_distance;
double
average_diesel_cost=total_cost/5.0;
System.out.println("The
average diesel consumption :"+average_diesel_consumption);
System.out.println("The
average cost of diesel :"+average_diesel_cost);
if(average_diesel_cost>=14)
System.out.println("The
average cost is above 14 cents");
else
System.out.println("The
average cost is below 14 cents");
}
}
- 단 Х eclipse-workspace - exampro/src/exampro/Exampro.java - Eclipse IDE File Edit Source Refactor Navigate Search Project Run Window Help 出 Po > > 11 Project Explorer module-info.java 2 *Exampro.java 回答 8 4 exampro 50 public static void main(String[] args) { 6 JRE System Library [Java // TODO Auto-generated method stub 7 Scanner sc= new Scanner(System.in); src 8 double[] litres_of_diesel_filled=new double[5]; # exampro 9 double[] cost_of_each_litre =new double[5]; module-info.java 10 double[] distance_travelled=new double[5]; double total_cost=0; 12 double total_litres_consumed=0; 13 double total_distance=0; 14 for(int i=0;i<5; i++) 15 { 16 System.out.println("Enter the amount of diesel filled for filling "+(i+1)+" :"); 17 litres_of_diesel_filled=sc.nextDouble(); System.out.println("Enter the cost of one litre of diesel for filling "+(i+1)+" :"); 19 cost_of_each_litre=sc.nextDouble(); 20 System.out.println("Enter the distance travelled for filling "+(i+1)+" :"); distance_travelled=sc.nextDouble(); 22 total_distance=total_distance+distance_travelled[i]; 23 total_litres consumed=total_litres_consumed+litres_of_diesel_filled[i]; 24 total_cost=total_cost+(cost_of_each_litre[i]*litres_of_diesel_filled[i]); 25 26 } 27 double average_diesel_consumption=total_litres_consumed/total_distance; 28 double average_diesel_cost=total_cost/5.0; 29 System.out.println("The average diesel consumption : "+average_diesel_consumption); 18 21 30 31 32 33 34 35 System.out.println("The average cost of diesel :"+average_diesel_cost); if(average_diesel_cost>=14) System.out.println("The average cost is above 14 cents"); else System.out.println("The average cost is below 14 cents"); 一则 監嗯啊 Problems Declaration Console X Coverage <terminated > Exampro [Java Application] C:\Users\Sagarmatha\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.2.v20220201-1208\jre\bin\javaw.exe (18 May 2022, 11:28:17
can you fix this out. I don't know where i have done mistake. package exampro; public class Exampro { public static void
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
can you fix this out. I don't know where i have done mistake. package exampro; public class Exampro { public static void
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!