SlideShare a Scribd company logo
1 of 7
Download to read offline
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;.pdfankitmobileshop235
 
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. .pdfindiaartz
 
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 exampleChristopher Curtin
 
Auto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK NodesAuto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK Nodesnihiliad
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Android Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android MeetupAndroid Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android MeetupRon Shapiro
 
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.5Martin 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 CodeDaniel 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 hackingJeroen van Dijk
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
Unidirectional Data Flow with Reactor
Unidirectional Data Flow with ReactorUnidirectional Data Flow with Reactor
Unidirectional Data Flow with ReactorJason 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.pdfanjalitimecenter11
 
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 .pdfanjalitimecenter11
 
NiCl2 because it not dissociate .pdf
                     NiCl2  because it not dissociate                 .pdf                     NiCl2  because it not dissociate                 .pdf
NiCl2 because it not dissociate .pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 
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 .pdfanjalitimecenter11
 
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).pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 
Systematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdf
Systematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdfSystematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdf
Systematic positionKingdom PlantaeSubkingdom Tracheobionta (Vas.pdfanjalitimecenter11
 
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 .pdfanjalitimecenter11
 
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) .pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 
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 .pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 
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.pdfanjalitimecenter11
 

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

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

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()); } }