SlideShare a Scribd company logo
1 of 3
Hi! Can everyone help me solve this java problem?
Write code that prints: Ready! firstNumber ... 2 1 Blastoff!
Your code should contain a for loop. Print a newline after each
number and after each line of text.
Ex: If the input is:
3
The output is:
Ready!
3
2
1
Blastoff!
This is my code:
import java.util.Scanner;
public class ForLoops {
public static void main (String [] args) {
int firstNumber;
int i;
Scanner input = new Scanner(System.in);
firstNumber = input.nextInt();
System.out.println("Ready!n"+firstNumber);
for (i=firstNumber;i>1; i--){
firstNumber--;
System.out.println(""+firstNumber);
}
System.out.println("Blastoff!");
}
}
When running the program, my output only matches the two
outputs as shown in the attached picture. The rest do not match.
How can my code be the same as the expected output as in the
attached image?
Thanks, everyone!
Hi! can everyone help me solve this java problem write code tha

More Related Content

Similar to Hi! can everyone help me solve this java problem write code tha

KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
Aiman Hud
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
wilcockiris
 

Similar to Hi! can everyone help me solve this java problem write code tha (18)

Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
Java Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting StartedJava Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting Started
 
gdscpython.pdf
gdscpython.pdfgdscpython.pdf
gdscpython.pdf
 
Anjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjalisoorej imca133 assignment
Anjalisoorej imca133 assignment
 
Hello. This program has to be done in Eclipse(Program used to write .pdf
Hello. This program has to be done in Eclipse(Program used to write .pdfHello. This program has to be done in Eclipse(Program used to write .pdf
Hello. This program has to be done in Eclipse(Program used to write .pdf
 
Algorithms with-java-1.0
Algorithms with-java-1.0Algorithms with-java-1.0
Algorithms with-java-1.0
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaan
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
Python in details
Python in detailsPython in details
Python in details
 
Star pattern programs in java Print Star pattern in java and print triangle ...
Star pattern programs in java Print Star pattern in java and  print triangle ...Star pattern programs in java Print Star pattern in java and  print triangle ...
Star pattern programs in java Print Star pattern in java and print triangle ...
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
 
Intro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample ProgramIntro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample Program
 
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part IIIntro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
 
The java code works, I just need it to display the results as in t.pdf
The java code works, I just need it to display the results as in t.pdfThe java code works, I just need it to display the results as in t.pdf
The java code works, I just need it to display the results as in t.pdf
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 

More from simba35

SYLLABUS ACC423 Intermediate Financial Accounting III Copyrig.docx
SYLLABUS ACC423 Intermediate Financial Accounting III Copyrig.docxSYLLABUS ACC423 Intermediate Financial Accounting III Copyrig.docx
SYLLABUS ACC423 Intermediate Financial Accounting III Copyrig.docx
simba35
 
Synthesis Assignment Instructions and RubricSynthesis Essay..docx
Synthesis Assignment Instructions and RubricSynthesis Essay..docxSynthesis Assignment Instructions and RubricSynthesis Essay..docx
Synthesis Assignment Instructions and RubricSynthesis Essay..docx
simba35
 
Sustainable Development Project OutlineFor the first step in the D.docx
Sustainable Development Project OutlineFor the first step in the D.docxSustainable Development Project OutlineFor the first step in the D.docx
Sustainable Development Project OutlineFor the first step in the D.docx
simba35
 
Sustainable Development Project Rough Draft After the outline, s.docx
Sustainable Development Project Rough Draft After the outline, s.docxSustainable Development Project Rough Draft After the outline, s.docx
Sustainable Development Project Rough Draft After the outline, s.docx
simba35
 
Suppose that you are currently employed as an Information Security M.docx
Suppose that you are currently employed as an Information Security M.docxSuppose that you are currently employed as an Information Security M.docx
Suppose that you are currently employed as an Information Security M.docx
simba35
 
Summer 2014 PHIL 1171 Ethics Final Essay Questions 1 Part One Ess.docx
Summer 2014 PHIL 1171 Ethics Final Essay Questions 1 Part One Ess.docxSummer 2014 PHIL 1171 Ethics Final Essay Questions 1 Part One Ess.docx
Summer 2014 PHIL 1171 Ethics Final Essay Questions 1 Part One Ess.docx
simba35
 

More from simba35 (20)

Symbols of culture are called artifacts. Artifacts are the most visi.docx
Symbols of culture are called artifacts. Artifacts are the most visi.docxSymbols of culture are called artifacts. Artifacts are the most visi.docx
Symbols of culture are called artifacts. Artifacts are the most visi.docx
 
SYLLABUS ACC423 Intermediate Financial Accounting III Copyrig.docx
SYLLABUS ACC423 Intermediate Financial Accounting III Copyrig.docxSYLLABUS ACC423 Intermediate Financial Accounting III Copyrig.docx
SYLLABUS ACC423 Intermediate Financial Accounting III Copyrig.docx
 
Synthesis Assignment Instructions and RubricSynthesis Essay..docx
Synthesis Assignment Instructions and RubricSynthesis Essay..docxSynthesis Assignment Instructions and RubricSynthesis Essay..docx
Synthesis Assignment Instructions and RubricSynthesis Essay..docx
 
Sustainable Development Project OutlineFor the first step in the D.docx
Sustainable Development Project OutlineFor the first step in the D.docxSustainable Development Project OutlineFor the first step in the D.docx
Sustainable Development Project OutlineFor the first step in the D.docx
 
Sustainable Development Project Rough Draft After the outline, s.docx
Sustainable Development Project Rough Draft After the outline, s.docxSustainable Development Project Rough Draft After the outline, s.docx
Sustainable Development Project Rough Draft After the outline, s.docx
 
Suppose you work as a human resource (HR) executive at Total Solutio.docx
Suppose you work as a human resource (HR) executive at Total Solutio.docxSuppose you work as a human resource (HR) executive at Total Solutio.docx
Suppose you work as a human resource (HR) executive at Total Solutio.docx
 
Supreme Court Responsiveness to Public Opinion    Please respond.docx
Supreme Court Responsiveness to Public Opinion    Please respond.docxSupreme Court Responsiveness to Public Opinion    Please respond.docx
Supreme Court Responsiveness to Public Opinion    Please respond.docx
 
Suppose we have an EOQ model as follows[1]  weekly demand = 100.docx
Suppose we have an EOQ model as follows[1]  weekly demand = 100.docxSuppose we have an EOQ model as follows[1]  weekly demand = 100.docx
Suppose we have an EOQ model as follows[1]  weekly demand = 100.docx
 
Suppose that you are currently employed as an Information Security M.docx
Suppose that you are currently employed as an Information Security M.docxSuppose that you are currently employed as an Information Security M.docx
Suppose that you are currently employed as an Information Security M.docx
 
Suppose the Cincinnati Reds increased the price of their tickets and.docx
Suppose the Cincinnati Reds increased the price of their tickets and.docxSuppose the Cincinnati Reds increased the price of their tickets and.docx
Suppose the Cincinnati Reds increased the price of their tickets and.docx
 
Suppose that there are two (2) candidates (i.e., Jones and Johns.docx
Suppose that there are two (2) candidates (i.e., Jones and Johns.docxSuppose that there are two (2) candidates (i.e., Jones and Johns.docx
Suppose that there are two (2) candidates (i.e., Jones and Johns.docx
 
Suppose that the reserve ratio is .25, and that a bank has actual re.docx
Suppose that the reserve ratio is .25, and that a bank has actual re.docxSuppose that the reserve ratio is .25, and that a bank has actual re.docx
Suppose that the reserve ratio is .25, and that a bank has actual re.docx
 
Supply side Options Quiz #4Requirements Arial 11’ 720 word .docx
Supply side Options Quiz #4Requirements Arial 11’ 720 word .docxSupply side Options Quiz #4Requirements Arial 11’ 720 word .docx
Supply side Options Quiz #4Requirements Arial 11’ 720 word .docx
 
Suppose a zoo wants a C++ program to keep track of its animals and t.docx
Suppose a zoo wants a C++ program to keep track of its animals and t.docxSuppose a zoo wants a C++ program to keep track of its animals and t.docx
Suppose a zoo wants a C++ program to keep track of its animals and t.docx
 
Support your statements with examples and scholarly references. Reme.docx
Support your statements with examples and scholarly references. Reme.docxSupport your statements with examples and scholarly references. Reme.docx
Support your statements with examples and scholarly references. Reme.docx
 
Summer 2014 PHIL 1171 Ethics Final Essay Questions 1 Part One Ess.docx
Summer 2014 PHIL 1171 Ethics Final Essay Questions 1 Part One Ess.docxSummer 2014 PHIL 1171 Ethics Final Essay Questions 1 Part One Ess.docx
Summer 2014 PHIL 1171 Ethics Final Essay Questions 1 Part One Ess.docx
 
Supply Chain.   The term  is used rather freely these days, but wh.docx
Supply Chain.   The term  is used rather freely these days, but wh.docxSupply Chain.   The term  is used rather freely these days, but wh.docx
Supply Chain.   The term  is used rather freely these days, but wh.docx
 
SummaryIn your first paper, you will provide the pros and cons of .docx
SummaryIn your first paper, you will provide the pros and cons of .docxSummaryIn your first paper, you will provide the pros and cons of .docx
SummaryIn your first paper, you will provide the pros and cons of .docx
 
Supported by the readings from Modules 10 and 11 (attached), and a.docx
Supported by the readings from Modules 10 and 11 (attached), and a.docxSupported by the readings from Modules 10 and 11 (attached), and a.docx
Supported by the readings from Modules 10 and 11 (attached), and a.docx
 
Summarize your financial situation and plans. Be sure to include pla.docx
Summarize your financial situation and plans. Be sure to include pla.docxSummarize your financial situation and plans. Be sure to include pla.docx
Summarize your financial situation and plans. Be sure to include pla.docx
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 

Hi! can everyone help me solve this java problem write code tha

  • 1. Hi! Can everyone help me solve this java problem? Write code that prints: Ready! firstNumber ... 2 1 Blastoff! Your code should contain a for loop. Print a newline after each number and after each line of text. Ex: If the input is: 3 The output is: Ready! 3 2 1 Blastoff! This is my code: import java.util.Scanner; public class ForLoops { public static void main (String [] args) { int firstNumber;
  • 2. int i; Scanner input = new Scanner(System.in); firstNumber = input.nextInt(); System.out.println("Ready!n"+firstNumber); for (i=firstNumber;i>1; i--){ firstNumber--; System.out.println(""+firstNumber); } System.out.println("Blastoff!"); } } When running the program, my output only matches the two outputs as shown in the attached picture. The rest do not match. How can my code be the same as the expected output as in the attached image? Thanks, everyone!