Question

In: Computer Science

This Compilation Errors Detected File: ALIEN_23547/source/domain/World.java Line: 153 while expected File: ALIEN_23547/source/domain/World.java Line: 158 reached end...

This Compilation Errors Detected

File: ALIEN_23547/source/domain/World.java
Line: 153
while expected

File: ALIEN_23547/source/domain/World.java

Line: 158
reached end of file while parsing

WHERE IS THE ERROR? HOW TO CORRECT IT? PLEASE PINPOINT THE ERROR


import java.util.Scanner;

public class World {

public static void main (String [] args){

Scanner scan = new Scanner (System.in);

double masse = 80.0;

do{

System.out.print("masse du parachutiste(>=40)?");

masse =scan.nextDouble();

}while (masse<40.0);

double h0= 39000.0;

do{

System.out.print("hauter de depart du parachutiste(>=250)?");

h0 = scan.nextDouble();

}while(h0<250.0);

final double g =9.81;

double v0= 0;

double t0 =0;

double t = 0;

double hauter = h0;

double vitesse = 0;

double accel = g;

double s0 =2;

boolean max = false;

boolean depass = false;

boolean ouv = false;

double s;

double q;

do{

s = s0/masse;

q = Math.exp(-s*(t-t0));

vitesse = (g/s)*(1-q)+v0*q;

hauteur = h0-(g/s)*(t-t0)-(v0-(g/s))/s*(1-q);

accel =g-s*vitesse;

if (vitesse>343 && depass == false){

System.out.println("##Felix depasse la vitesse du son");

depass = true;

if (accel<0.5 && max == false){

System.out.println("Felix a attaint sa vitesse maximale");

max =true;

}

if(hauteur<2500 && ouv ==false && t !=0){

System.out.println("##Felix ouvre son parachute");

ouv =true;

}

System.out.format("%.0f, %.4f, %.4f, %.5f\n", t, hauteur, vitesse, accel);

t++;

}while(hauteur >=2500);

s0 =25;

s= s0/masse;

h0=hauteur;

v0= vitesse;

t0= t-1;

do{

q = Math.exp(-s*(t-t0));

vitessse = (g/s)*(1-q)+v0*q;

hauteur=h0-(g/s)*(t-t0)-(v0-(g/s))/s*(1-q);

accel =g-s*vitesse;

if (hauteur >2500){

if (hauteur <2500 && ouv == false && t != 0) {

System.out.println("## Felix ouvre son parachute");

ouv=true;

}

if(accel <0.5 && max == false){

System.out.println("##Felix a atteint sa vitesse maximale");

max =true;

}

}

if (hauteur >0){

System.out.format("%.0f, %.4f, %.4f, %.5f\n", t, hauter, vitesse, accel);

}

t++;

}while (hauteur>0);

clavier.close();

}

}

Solutions

Expert Solution

  • Check the following statement in your code:

if (vitesse>343 && depass == false){

System.out.println("##Felix depasse la vitesse du son");

depass = true;

  • The if body in not closed with }
  • So, there will be one less } in the end. Since this if statment appears inside a do-while, The compiler expects you add a closing brace } at the end and add a while statement.
  • After we rectify this error by adding a closing brace to the body of this if statement, we get more errors in the program
  • Many of those errors are typos, like "hauteur" being misspelled as "hauter", "vitesse" being misspelled as "vitessse". This can be corrected by changing the spelling here and there.
  • However, there is an undefined variable at the end, "clavier", this variable is not found anywhere in the program, removing it does not seem to produce any anamoly in the output. so let's just remove it.

modified code:


import java.util.Scanner;

public class World {

public static void main (String [] args){

Scanner scan = new Scanner (System.in);

double masse = 39.0;

do{

System.out.print("masse du parachutiste(>=40)?");

masse =scan.nextDouble();

}while (masse<40.0);

double h0= 39000.0;

do{

System.out.print("hauter de depart du parachutiste(>=250)?");

h0 = scan.nextDouble();

}while(h0<250.0);

final double g =9.81;

double v0= 0;

double t0 =0;

double t = 0;

double hauteur = h0;

double vitesse = 0;

double accel = g;

double s0 =2;

boolean max = false;

boolean depass = false;

boolean ouv = false;

double s;

double q;

do{

s = s0/masse;

q = Math.exp(-s*(t-t0));

vitesse = (g/s)*(1-q)+v0*q;

hauteur = h0-(g/s)*(t-t0)-(v0-(g/s))/s*(1-q);

accel =g-s*vitesse;

if (vitesse>343 && depass == false){

System.out.println("##Felix depasse la vitesse du son");

depass = true;
}

if (accel<0.5 && max == false){

System.out.println("Felix a attaint sa vitesse maximale");

max =true;

}

if(hauteur<2500 && ouv ==false && t !=0){

System.out.println("##Felix ouvre son parachute");

ouv =true;

}

System.out.format("%.0f, %.4f, %.4f, %.5f\n", t, hauteur, vitesse, accel);

t++;

}while(hauteur >=2500);

s0 =25;

s= s0/masse;

h0=hauteur;

v0= vitesse;

t0= t-1;

do{

q = Math.exp(-s*(t-t0));

vitesse = (g/s)*(1-q)+v0*q;

hauteur=h0-(g/s)*(t-t0)-(v0-(g/s))/s*(1-q);

accel =g-s*vitesse;

if (hauteur >2500){

if (hauteur <2500 && ouv == false && t != 0) {

System.out.println("## Felix ouvre son parachute");

ouv=true;

}

if(accel <0.5 && max == false){

System.out.println("##Felix a atteint sa vitesse maximale");

max =true;

}

}

if (hauteur >0){

System.out.format("%.0f, %.4f, %.4f, %.5f\n", t, hauteur, vitesse, accel);

}

t++;

}while (hauteur>0);


}

}

sample input and output:


Related Solutions

BSTree.java:99: error: reached end of file while parsing } I get this error when i run...
BSTree.java:99: error: reached end of file while parsing } I get this error when i run this code. can someone help me out? I can't figure out how to make this work. public class BSTree<T extends Comparable<T>> { private BSTreeNode<T> root = null; // TODO: Write an addElement method that inserts generic Nodes into // the generic tree. You will need to use a Comparable Object public boolean isEmpty(){ return root == null; } public int size(){ return node;} public...
Use a while loop to read each line in the file modified_etc_passwd directly and process each...
Use a while loop to read each line in the file modified_etc_passwd directly and process each line as follows:  Use a combination of the echo and cut commands to assign the contents of the home directory field of the current record to a variable called homedir  Use a combination of the echo and cut commands to assign the contents of the username field to a variable called username  If homedir exists as a directory o Use a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT