SlideShare a Scribd company logo
public class LunarLander
{
double currentFuelFlowRate;
double verticalSpeed;
double altitude;
double amountOfFuel;
double massOfTheLander;
double maxFuelConsumptionRate;
double maxThrust;
/* constructor to initialize member variales*/
public LunarLander(double al, double fuel, double mass, double rate, double thrust)
{
currentFuelFlowRate=0.0;
verticalSpeed=0.0;
altitude=al;
amountOfFuel=fuel;
massOfTheLander=mass;
maxFuelConsumptionRate=rate;
maxThrust=thrust;
}
/* functions to get the values of instance variables*/
public double getCurrentFuelFlowRate()
{
return currentFuelFlowRate;
}
public double getVerticalSpeed()
{
return verticalSpeed;
}
public double getAltitude()
{
return altitude;
}
public double getAmountOfFuel()
{
return amountOfFuel;
}
public double getMassOfTheLander()
{
return massOfTheLander;
}
public double getMaxFuelConsumptionRate()
{
return maxFuelConsumptionRate;
}
public double getMaxThrust()
{
return maxThrust;
}
/* updates the value of currentFuelFlowRate*/
public void setCurrentFuelFlowRate(double rate)
{
currentFuelFlowRate=rate;
}
/* simulating the passage for a small amount of time t*/
public void setPassage(double t)
{
if(currentFuelFlowRate>0)
{
if(amountOfFuel==0)
{
currentFuelFlowRate=0;
}
}
/* velocity is the verticalSpeed*/
double f=maxThrust*currentFuelFlowRate;
double m=massOfTheLander;
verticalSpeed=t*((f/m)-1.62);
//v is verticalSpeed
altitude=t*verticalSpeed;
//ship is landed
if(altitude<0)
{
altitude=0;
verticalSpeed=0;
}
//r is currentFuelFlowRate
//c is maxFuelConsumptionRate
double changeInRemainFuel=t*currentFuelFlowRate*maxFuelConsumptionRate;
amountOfFuel=amountOfFuel-changeInRemainFuel;
if(amountOfFuel<0)
{
amountOfFuel=0;
}
}
}
////////////////////////////////////////////////////////
public class LunarLanderDemo {
public static void main(String[] args) {
LunarLander L=new LunarLander(1000,1700,900,10,5000);
/*give values between 0.0 , 1.0*/
L.setCurrentFuelFlowRate(0.6);
L.setPassage(0.1);
System.out.println("Simulation of Lunar Lander Passage at 0.1 seconds");
System.out.println("Current Fuel Flow Rate: "+L.getCurrentFuelFlowRate());
System.out.println("Vertical Speed: "+L.getVerticalSpeed());
System.out.println("Altitude: "+L.getAltitude());
System.out.println("Amount of Fuel: "+L.getAmountOfFuel());
L.setCurrentFuelFlowRate(0.3);
L.setPassage(0.09);
System.out.println("Simulation of Lunar Lander Passage at 0.09 seconds");
System.out.println("Current Fuel Flow Rate: "+L.getCurrentFuelFlowRate());
System.out.println("Vertical Speed: "+L.getVerticalSpeed());
System.out.println("Altitude: "+L.getAltitude());
System.out.println("Amount of Fuel: "+L.getAmountOfFuel());
}
}
Solution
public class LunarLander
{
double currentFuelFlowRate;
double verticalSpeed;
double altitude;
double amountOfFuel;
double massOfTheLander;
double maxFuelConsumptionRate;
double maxThrust;
/* constructor to initialize member variales*/
public LunarLander(double al, double fuel, double mass, double rate, double thrust)
{
currentFuelFlowRate=0.0;
verticalSpeed=0.0;
altitude=al;
amountOfFuel=fuel;
massOfTheLander=mass;
maxFuelConsumptionRate=rate;
maxThrust=thrust;
}
/* functions to get the values of instance variables*/
public double getCurrentFuelFlowRate()
{
return currentFuelFlowRate;
}
public double getVerticalSpeed()
{
return verticalSpeed;
}
public double getAltitude()
{
return altitude;
}
public double getAmountOfFuel()
{
return amountOfFuel;
}
public double getMassOfTheLander()
{
return massOfTheLander;
}
public double getMaxFuelConsumptionRate()
{
return maxFuelConsumptionRate;
}
public double getMaxThrust()
{
return maxThrust;
}
/* updates the value of currentFuelFlowRate*/
public void setCurrentFuelFlowRate(double rate)
{
currentFuelFlowRate=rate;
}
/* simulating the passage for a small amount of time t*/
public void setPassage(double t)
{
if(currentFuelFlowRate>0)
{
if(amountOfFuel==0)
{
currentFuelFlowRate=0;
}
}
/* velocity is the verticalSpeed*/
double f=maxThrust*currentFuelFlowRate;
double m=massOfTheLander;
verticalSpeed=t*((f/m)-1.62);
//v is verticalSpeed
altitude=t*verticalSpeed;
//ship is landed
if(altitude<0)
{
altitude=0;
verticalSpeed=0;
}
//r is currentFuelFlowRate
//c is maxFuelConsumptionRate
double changeInRemainFuel=t*currentFuelFlowRate*maxFuelConsumptionRate;
amountOfFuel=amountOfFuel-changeInRemainFuel;
if(amountOfFuel<0)
{
amountOfFuel=0;
}
}
}
////////////////////////////////////////////////////////
public class LunarLanderDemo {
public static void main(String[] args) {
LunarLander L=new LunarLander(1000,1700,900,10,5000);
/*give values between 0.0 , 1.0*/
L.setCurrentFuelFlowRate(0.6);
L.setPassage(0.1);
System.out.println("Simulation of Lunar Lander Passage at 0.1 seconds");
System.out.println("Current Fuel Flow Rate: "+L.getCurrentFuelFlowRate());
System.out.println("Vertical Speed: "+L.getVerticalSpeed());
System.out.println("Altitude: "+L.getAltitude());
System.out.println("Amount of Fuel: "+L.getAmountOfFuel());
L.setCurrentFuelFlowRate(0.3);
L.setPassage(0.09);
System.out.println("Simulation of Lunar Lander Passage at 0.09 seconds");
System.out.println("Current Fuel Flow Rate: "+L.getCurrentFuelFlowRate());
System.out.println("Vertical Speed: "+L.getVerticalSpeed());
System.out.println("Altitude: "+L.getAltitude());
System.out.println("Amount of Fuel: "+L.getAmountOfFuel());
}
}

More Related Content

Similar to public class LunarLander {    double currentFuelFlowRate;    d.pdf

Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdf
ankitmobileshop235
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdf
indiaartz
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)
RichardWarburton
 
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JSFestUA
 
AJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleAJUG April 2011 Cascading example
AJUG April 2011 Cascading example
Christopher Curtin
 
Auto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK NodesAuto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK Nodesnihiliad
 
Hack tutorial
Hack tutorialHack tutorial
Hack tutorial
Wakana Yoshizawa
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
Jonathan Wage
 
Android Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android MeetupAndroid Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android Meetup
Ron Shapiro
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
Domingos Salvador
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
Domingos Salvador
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
Domingos Salvador
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Developmentjsmith92
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
Martin Kleppe
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
Daniel Wellman
 
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
DevClub_lv
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
Jeroen van Dijk
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
Mark Baker
 
Unidirectional Data Flow with Reactor
Unidirectional Data Flow with ReactorUnidirectional Data Flow with Reactor
Unidirectional Data Flow with Reactor
Jason Larsen
 

Similar to public class LunarLander {    double currentFuelFlowRate;    d.pdf (20)

Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdf
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdf
 
slides
slidesslides
slides
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)
 
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
 
AJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleAJUG April 2011 Cascading example
AJUG April 2011 Cascading example
 
Auto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK NodesAuto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK Nodes
 
Hack tutorial
Hack tutorialHack tutorial
Hack tutorial
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Android Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android MeetupAndroid Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android Meetup
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Unidirectional Data Flow with Reactor
Unidirectional Data Flow with ReactorUnidirectional Data Flow with Reactor
Unidirectional Data Flow with Reactor
 

More from anjalitimecenter11

O = O bond is shortest Oxygen electronegativity d.pdf
                     O = O bond is shortest Oxygen electronegativity d.pdf                     O = O bond is shortest Oxygen electronegativity d.pdf
O = O bond is shortest Oxygen electronegativity d.pdf
anjalitimecenter11
 
NaCl Na is the symbol for Sodium which bonds to .pdf
                     NaCl  Na is the symbol for Sodium which bonds to .pdf                     NaCl  Na is the symbol for Sodium which bonds to .pdf
NaCl Na is the symbol for Sodium which bonds to .pdf
anjalitimecenter11
 
NiCl2 because it not dissociate .pdf
                     NiCl2  because it not dissociate                 .pdf                     NiCl2  because it not dissociate                 .pdf
NiCl2 because it not dissociate .pdf
anjalitimecenter11
 
iodide, I-, has the -1 oxidation state. iodine (I.pdf
                     iodide, I-, has the -1 oxidation state. iodine (I.pdf                     iodide, I-, has the -1 oxidation state. iodine (I.pdf
iodide, I-, has the -1 oxidation state. iodine (I.pdf
anjalitimecenter11
 
Lithium is in group 1 on the peridic table. This .pdf
                     Lithium is in group 1 on the peridic table. This .pdf                     Lithium is in group 1 on the peridic table. This .pdf
Lithium is in group 1 on the peridic table. This .pdf
anjalitimecenter11
 
{}Solution{}.pdf
{}Solution{}.pdf{}Solution{}.pdf
{}Solution{}.pdf
anjalitimecenter11
 
y=2sin(2pix3)Solutiony=2sin(2pix3).pdf
y=2sin(2pix3)Solutiony=2sin(2pix3).pdfy=2sin(2pix3)Solutiony=2sin(2pix3).pdf
y=2sin(2pix3)Solutiony=2sin(2pix3).pdf
anjalitimecenter11
 
Solution1.cpp#include iostreamheader for input output function.pdf
Solution1.cpp#include iostreamheader for input output function.pdfSolution1.cpp#include iostreamheader for input output function.pdf
Solution1.cpp#include iostreamheader for input output function.pdf
anjalitimecenter11
 
Systematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdf
Systematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdfSystematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdf
Systematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdf
anjalitimecenter11
 
Query to list out all the languages in the table LANGUAGES.SELECT .pdf
Query to list out all the languages in the table LANGUAGES.SELECT .pdfQuery to list out all the languages in the table LANGUAGES.SELECT .pdf
Query to list out all the languages in the table LANGUAGES.SELECT .pdf
anjalitimecenter11
 
Cooling. The reaction is giving off energy(heat) .pdf
                     Cooling. The reaction is giving off energy(heat) .pdf                     Cooling. The reaction is giving off energy(heat) .pdf
Cooling. The reaction is giving off energy(heat) .pdf
anjalitimecenter11
 
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdfphp global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
anjalitimecenter11
 
c. cytochrome C It is the enzyme involved in the .pdf
                     c. cytochrome C It is the enzyme involved in the .pdf                     c. cytochrome C It is the enzyme involved in the .pdf
c. cytochrome C It is the enzyme involved in the .pdf
anjalitimecenter11
 
Ka=-log(Ka)=-log(5.610^-10)=9.25 According to Henderson Hasselb.pdf
Ka=-log(Ka)=-log(5.610^-10)=9.25 According to Henderson Hasselb.pdfKa=-log(Ka)=-log(5.610^-10)=9.25 According to Henderson Hasselb.pdf
Ka=-log(Ka)=-log(5.610^-10)=9.25 According to Henderson Hasselb.pdf
anjalitimecenter11
 
C is wrong 14 7N contains 7 protons and 7 neutron.pdf
                     C is wrong 14 7N contains 7 protons and 7 neutron.pdf                     C is wrong 14 7N contains 7 protons and 7 neutron.pdf
C is wrong 14 7N contains 7 protons and 7 neutron.pdf
anjalitimecenter11
 
1.The following are the main types of service providers to a mutua.pdf
1.The following are the main types of service providers to a mutua.pdf1.The following are the main types of service providers to a mutua.pdf
1.The following are the main types of service providers to a mutua.pdf
anjalitimecenter11
 
D. planned and directed means to improve the functioning of the clie.pdf
D. planned and directed means to improve the functioning of the clie.pdfD. planned and directed means to improve the functioning of the clie.pdf
D. planned and directed means to improve the functioning of the clie.pdf
anjalitimecenter11
 
domain - -x-1 0 = x+10 =x-1i.e. (-inf,-1)range-(-in.pdf
domain - -x-1 0 = x+10 =x-1i.e. (-inf,-1)range-(-in.pdfdomain - -x-1 0 = x+10 =x-1i.e. (-inf,-1)range-(-in.pdf
domain - -x-1 0 = x+10 =x-1i.e. (-inf,-1)range-(-in.pdf
anjalitimecenter11
 
B.both are correctSolutionB.both are correct.pdf
B.both are correctSolutionB.both are correct.pdfB.both are correctSolutionB.both are correct.pdf
B.both are correctSolutionB.both are correct.pdf
anjalitimecenter11
 
C. Keystroke loggers are a form of malware that records every key th.pdf
C. Keystroke loggers are a form of malware that records every key th.pdfC. Keystroke loggers are a form of malware that records every key th.pdf
C. Keystroke loggers are a form of malware that records every key th.pdf
anjalitimecenter11
 

More from anjalitimecenter11 (20)

O = O bond is shortest Oxygen electronegativity d.pdf
                     O = O bond is shortest Oxygen electronegativity d.pdf                     O = O bond is shortest Oxygen electronegativity d.pdf
O = O bond is shortest Oxygen electronegativity d.pdf
 
NaCl Na is the symbol for Sodium which bonds to .pdf
                     NaCl  Na is the symbol for Sodium which bonds to .pdf                     NaCl  Na is the symbol for Sodium which bonds to .pdf
NaCl Na is the symbol for Sodium which bonds to .pdf
 
NiCl2 because it not dissociate .pdf
                     NiCl2  because it not dissociate                 .pdf                     NiCl2  because it not dissociate                 .pdf
NiCl2 because it not dissociate .pdf
 
iodide, I-, has the -1 oxidation state. iodine (I.pdf
                     iodide, I-, has the -1 oxidation state. iodine (I.pdf                     iodide, I-, has the -1 oxidation state. iodine (I.pdf
iodide, I-, has the -1 oxidation state. iodine (I.pdf
 
Lithium is in group 1 on the peridic table. This .pdf
                     Lithium is in group 1 on the peridic table. This .pdf                     Lithium is in group 1 on the peridic table. This .pdf
Lithium is in group 1 on the peridic table. This .pdf
 
{}Solution{}.pdf
{}Solution{}.pdf{}Solution{}.pdf
{}Solution{}.pdf
 
y=2sin(2pix3)Solutiony=2sin(2pix3).pdf
y=2sin(2pix3)Solutiony=2sin(2pix3).pdfy=2sin(2pix3)Solutiony=2sin(2pix3).pdf
y=2sin(2pix3)Solutiony=2sin(2pix3).pdf
 
Solution1.cpp#include iostreamheader for input output function.pdf
Solution1.cpp#include iostreamheader for input output function.pdfSolution1.cpp#include iostreamheader for input output function.pdf
Solution1.cpp#include iostreamheader for input output function.pdf
 
Systematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdf
Systematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdfSystematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdf
Systematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdf
 
Query to list out all the languages in the table LANGUAGES.SELECT .pdf
Query to list out all the languages in the table LANGUAGES.SELECT .pdfQuery to list out all the languages in the table LANGUAGES.SELECT .pdf
Query to list out all the languages in the table LANGUAGES.SELECT .pdf
 
Cooling. The reaction is giving off energy(heat) .pdf
                     Cooling. The reaction is giving off energy(heat) .pdf                     Cooling. The reaction is giving off energy(heat) .pdf
Cooling. The reaction is giving off energy(heat) .pdf
 
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdfphp global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
 
c. cytochrome C It is the enzyme involved in the .pdf
                     c. cytochrome C It is the enzyme involved in the .pdf                     c. cytochrome C It is the enzyme involved in the .pdf
c. cytochrome C It is the enzyme involved in the .pdf
 
Ka=-log(Ka)=-log(5.610^-10)=9.25 According to Henderson Hasselb.pdf
Ka=-log(Ka)=-log(5.610^-10)=9.25 According to Henderson Hasselb.pdfKa=-log(Ka)=-log(5.610^-10)=9.25 According to Henderson Hasselb.pdf
Ka=-log(Ka)=-log(5.610^-10)=9.25 According to Henderson Hasselb.pdf
 
C is wrong 14 7N contains 7 protons and 7 neutron.pdf
                     C is wrong 14 7N contains 7 protons and 7 neutron.pdf                     C is wrong 14 7N contains 7 protons and 7 neutron.pdf
C is wrong 14 7N contains 7 protons and 7 neutron.pdf
 
1.The following are the main types of service providers to a mutua.pdf
1.The following are the main types of service providers to a mutua.pdf1.The following are the main types of service providers to a mutua.pdf
1.The following are the main types of service providers to a mutua.pdf
 
D. planned and directed means to improve the functioning of the clie.pdf
D. planned and directed means to improve the functioning of the clie.pdfD. planned and directed means to improve the functioning of the clie.pdf
D. planned and directed means to improve the functioning of the clie.pdf
 
domain - -x-1 0 = x+10 =x-1i.e. (-inf,-1)range-(-in.pdf
domain - -x-1 0 = x+10 =x-1i.e. (-inf,-1)range-(-in.pdfdomain - -x-1 0 = x+10 =x-1i.e. (-inf,-1)range-(-in.pdf
domain - -x-1 0 = x+10 =x-1i.e. (-inf,-1)range-(-in.pdf
 
B.both are correctSolutionB.both are correct.pdf
B.both are correctSolutionB.both are correct.pdfB.both are correctSolutionB.both are correct.pdf
B.both are correctSolutionB.both are correct.pdf
 
C. Keystroke loggers are a form of malware that records every key th.pdf
C. Keystroke loggers are a form of malware that records every key th.pdfC. Keystroke loggers are a form of malware that records every key th.pdf
C. Keystroke loggers are a form of malware that records every key th.pdf
 

Recently uploaded

Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 

Recently uploaded (20)

Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 

public class LunarLander {    double currentFuelFlowRate;    d.pdf

  • 1. public class LunarLander { double currentFuelFlowRate; double verticalSpeed; double altitude; double amountOfFuel; double massOfTheLander; double maxFuelConsumptionRate; double maxThrust; /* constructor to initialize member variales*/ public LunarLander(double al, double fuel, double mass, double rate, double thrust) { currentFuelFlowRate=0.0; verticalSpeed=0.0; altitude=al; amountOfFuel=fuel; massOfTheLander=mass; maxFuelConsumptionRate=rate; maxThrust=thrust; } /* functions to get the values of instance variables*/ public double getCurrentFuelFlowRate() { return currentFuelFlowRate; } public double getVerticalSpeed() { return verticalSpeed; } public double getAltitude() { return altitude; } public double getAmountOfFuel()
  • 2. { return amountOfFuel; } public double getMassOfTheLander() { return massOfTheLander; } public double getMaxFuelConsumptionRate() { return maxFuelConsumptionRate; } public double getMaxThrust() { return maxThrust; } /* updates the value of currentFuelFlowRate*/ public void setCurrentFuelFlowRate(double rate) { currentFuelFlowRate=rate; } /* simulating the passage for a small amount of time t*/ public void setPassage(double t) { if(currentFuelFlowRate>0) { if(amountOfFuel==0) { currentFuelFlowRate=0; } } /* velocity is the verticalSpeed*/ double f=maxThrust*currentFuelFlowRate; double m=massOfTheLander; verticalSpeed=t*((f/m)-1.62); //v is verticalSpeed altitude=t*verticalSpeed;
  • 3. //ship is landed if(altitude<0) { altitude=0; verticalSpeed=0; } //r is currentFuelFlowRate //c is maxFuelConsumptionRate double changeInRemainFuel=t*currentFuelFlowRate*maxFuelConsumptionRate; amountOfFuel=amountOfFuel-changeInRemainFuel; if(amountOfFuel<0) { amountOfFuel=0; } } } //////////////////////////////////////////////////////// public class LunarLanderDemo { public static void main(String[] args) { LunarLander L=new LunarLander(1000,1700,900,10,5000); /*give values between 0.0 , 1.0*/ L.setCurrentFuelFlowRate(0.6); L.setPassage(0.1); System.out.println("Simulation of Lunar Lander Passage at 0.1 seconds"); System.out.println("Current Fuel Flow Rate: "+L.getCurrentFuelFlowRate()); System.out.println("Vertical Speed: "+L.getVerticalSpeed()); System.out.println("Altitude: "+L.getAltitude()); System.out.println("Amount of Fuel: "+L.getAmountOfFuel()); L.setCurrentFuelFlowRate(0.3); L.setPassage(0.09); System.out.println("Simulation of Lunar Lander Passage at 0.09 seconds"); System.out.println("Current Fuel Flow Rate: "+L.getCurrentFuelFlowRate()); System.out.println("Vertical Speed: "+L.getVerticalSpeed()); System.out.println("Altitude: "+L.getAltitude());
  • 4. System.out.println("Amount of Fuel: "+L.getAmountOfFuel()); } } Solution public class LunarLander { double currentFuelFlowRate; double verticalSpeed; double altitude; double amountOfFuel; double massOfTheLander; double maxFuelConsumptionRate; double maxThrust; /* constructor to initialize member variales*/ public LunarLander(double al, double fuel, double mass, double rate, double thrust) { currentFuelFlowRate=0.0; verticalSpeed=0.0; altitude=al; amountOfFuel=fuel; massOfTheLander=mass; maxFuelConsumptionRate=rate; maxThrust=thrust; } /* functions to get the values of instance variables*/ public double getCurrentFuelFlowRate() { return currentFuelFlowRate; } public double getVerticalSpeed() { return verticalSpeed;
  • 5. } public double getAltitude() { return altitude; } public double getAmountOfFuel() { return amountOfFuel; } public double getMassOfTheLander() { return massOfTheLander; } public double getMaxFuelConsumptionRate() { return maxFuelConsumptionRate; } public double getMaxThrust() { return maxThrust; } /* updates the value of currentFuelFlowRate*/ public void setCurrentFuelFlowRate(double rate) { currentFuelFlowRate=rate; } /* simulating the passage for a small amount of time t*/ public void setPassage(double t) { if(currentFuelFlowRate>0) { if(amountOfFuel==0) { currentFuelFlowRate=0; } }
  • 6. /* velocity is the verticalSpeed*/ double f=maxThrust*currentFuelFlowRate; double m=massOfTheLander; verticalSpeed=t*((f/m)-1.62); //v is verticalSpeed altitude=t*verticalSpeed; //ship is landed if(altitude<0) { altitude=0; verticalSpeed=0; } //r is currentFuelFlowRate //c is maxFuelConsumptionRate double changeInRemainFuel=t*currentFuelFlowRate*maxFuelConsumptionRate; amountOfFuel=amountOfFuel-changeInRemainFuel; if(amountOfFuel<0) { amountOfFuel=0; } } } //////////////////////////////////////////////////////// public class LunarLanderDemo { public static void main(String[] args) { LunarLander L=new LunarLander(1000,1700,900,10,5000); /*give values between 0.0 , 1.0*/ L.setCurrentFuelFlowRate(0.6); L.setPassage(0.1); System.out.println("Simulation of Lunar Lander Passage at 0.1 seconds"); System.out.println("Current Fuel Flow Rate: "+L.getCurrentFuelFlowRate()); System.out.println("Vertical Speed: "+L.getVerticalSpeed()); System.out.println("Altitude: "+L.getAltitude()); System.out.println("Amount of Fuel: "+L.getAmountOfFuel());
  • 7. L.setCurrentFuelFlowRate(0.3); L.setPassage(0.09); System.out.println("Simulation of Lunar Lander Passage at 0.09 seconds"); System.out.println("Current Fuel Flow Rate: "+L.getCurrentFuelFlowRate()); System.out.println("Vertical Speed: "+L.getVerticalSpeed()); System.out.println("Altitude: "+L.getAltitude()); System.out.println("Amount of Fuel: "+L.getAmountOfFuel()); } }