SlideShare a Scribd company logo
1 of 3
JAVAASSIGNMENT-1
1.Create a Java program called GasCalculator that asks the user to input the size of a tank of gas (in gallons), the gas mileage of
a car (in miles per gallon), and the cost of gas (in rupees per gallon), and then displays how much it would cost to fill the tank
and how many miles the car can be driven on a full tank. Make sure that the program explains clearly what each input should
be when it asks for them and also explains what the outputs represent when they are printed to the screen.
2.Design and implement an application Password.java that produces and prints a random password. The password is composed
of random digits 0-9 and characters a-z. The first element is a character, the second is a digit, then a character, a digit, a
character, a digit, a character, and a digit (8 elements in total). An example is: e5c8a0b6.
3.Design and implement an application called MonsterGame.java that simulates a simple game. You have three magic arrows
to kill an evil monster. When you fire an arrow, the program generates a random integer between 0 and 10 (including 0 and 10).
This number shows how much damage you did to the monster. The monster has 10 energy points initially. After each arrow is
fired (by simply printing a message that says it was fired and shows the random number), the monster’s energy is decreased by
the generated number (but not decreased below zero). After you fire the first arrow, if the monster’s energy is zero, print the
message “You won!!!”; otherwise you fire the second arrow. After you fire the second arrow, if the monster’s energy is zero,
you win; otherwise you fire the third arrow. If in the end the energy is zero, you win; otherwise, print the message: “Nice try.
Almost there!”. After each arrow is fired, print a message with the current energy level left for the monster. After the game is
over, print the message “Do you want to play again? (y/n)”, and allow the user to play as many times as desired.
Java assignment 1

More Related Content

Viewers also liked

Twitter by the Numbers (Columbia University)
Twitter by the Numbers (Columbia University)Twitter by the Numbers (Columbia University)
Twitter by the Numbers (Columbia University)Raffi Krikorian
 
Exemples de bones pràctiques: L'evolució
Exemples de bones pràctiques: L'evolucióExemples de bones pràctiques: L'evolució
Exemples de bones pràctiques: L'evolucióCFA Jacint Verdaguer
 
UX para VR - by Robson Pereira
UX para VR - by Robson PereiraUX para VR - by Robson Pereira
UX para VR - by Robson PereiraUX Overdrive
 
Modul 1 Pengkelasan Media
Modul 1 Pengkelasan MediaModul 1 Pengkelasan Media
Modul 1 Pengkelasan Medianabilah001
 

Viewers also liked (6)

Twitter by the Numbers (Columbia University)
Twitter by the Numbers (Columbia University)Twitter by the Numbers (Columbia University)
Twitter by the Numbers (Columbia University)
 
Exemples de bones pràctiques: L'evolució
Exemples de bones pràctiques: L'evolucióExemples de bones pràctiques: L'evolució
Exemples de bones pràctiques: L'evolució
 
Evaluación del aprendizaje: pruebas escritas
Evaluación del aprendizaje: pruebas escritasEvaluación del aprendizaje: pruebas escritas
Evaluación del aprendizaje: pruebas escritas
 
UX para VR - by Robson Pereira
UX para VR - by Robson PereiraUX para VR - by Robson Pereira
UX para VR - by Robson Pereira
 
Modul 1 Pengkelasan Media
Modul 1 Pengkelasan MediaModul 1 Pengkelasan Media
Modul 1 Pengkelasan Media
 
my_cv[1]
my_cv[1]my_cv[1]
my_cv[1]
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
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
 
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
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
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
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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🔝
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
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
 
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🔝
 
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
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.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
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
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
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Java assignment 1

  • 2. 1.Create a Java program called GasCalculator that asks the user to input the size of a tank of gas (in gallons), the gas mileage of a car (in miles per gallon), and the cost of gas (in rupees per gallon), and then displays how much it would cost to fill the tank and how many miles the car can be driven on a full tank. Make sure that the program explains clearly what each input should be when it asks for them and also explains what the outputs represent when they are printed to the screen. 2.Design and implement an application Password.java that produces and prints a random password. The password is composed of random digits 0-9 and characters a-z. The first element is a character, the second is a digit, then a character, a digit, a character, a digit, a character, and a digit (8 elements in total). An example is: e5c8a0b6. 3.Design and implement an application called MonsterGame.java that simulates a simple game. You have three magic arrows to kill an evil monster. When you fire an arrow, the program generates a random integer between 0 and 10 (including 0 and 10). This number shows how much damage you did to the monster. The monster has 10 energy points initially. After each arrow is fired (by simply printing a message that says it was fired and shows the random number), the monster’s energy is decreased by the generated number (but not decreased below zero). After you fire the first arrow, if the monster’s energy is zero, print the message “You won!!!”; otherwise you fire the second arrow. After you fire the second arrow, if the monster’s energy is zero, you win; otherwise you fire the third arrow. If in the end the energy is zero, you win; otherwise, print the message: “Nice try. Almost there!”. After each arrow is fired, print a message with the current energy level left for the monster. After the game is over, print the message “Do you want to play again? (y/n)”, and allow the user to play as many times as desired.