SlideShare a Scribd company logo

Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docx

D
D

Write a SIMPLE java program to print out the numbers from 100 to 1, with the following conditions: If the number ends in 4, don\'t print it; instead, print \"hello\" If the number is a multiple of 6, don\'t print it; instead print \"world\" If the number is both a multiple of 6 and ends in 4, don\'t print it, instead print \"hello world\" Solution import java.util.Scanner; class Helloworld { public static void main(String []args) { Scanner input = new Scanner(System.in); int num=100; System.out.println(\"Input your number and press enter: \"); if(num== 4) { System.out.println(\"Hello\"); } else if(num==6) { System.out.println(\"world\"); } else { System.out.println(\"Hello world\"); } } } .

Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docx

1 of 2
Download to read offline
Write a SIMPLE java program to print out the numbers from 100 to 1, with the following
conditions:
If the number ends in 4, don't print it; instead, print "hello"
If the number is a multiple of 6, don't print it; instead print "world"
If the number is both a multiple of 6 and ends in 4, don't print it, instead print "hello world"
Solution
import java.util.Scanner;
class Helloworld
{
public static void main(String []args)
{
Scanner input = new Scanner(System.in);
int num=100;
System.out.println("Input your number and press enter: ");
if(num== 4)
{
System.out.println("Hello");
}
else if(num==6)
{
System.out.println("world");
}
else
{
System.out.println("Hello world");
}
}
}
Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docx
Ad

Recommended

Write a simple c++ program that computes the value of ex by using the.docx
Write a simple c++ program that computes the value of ex by using the.docxWrite a simple c++ program that computes the value of ex by using the.docx
Write a simple c++ program that computes the value of ex by using the.docxdrosa1
 
Write a short assembly language module to be used with C++ that rotate.docx
Write a short assembly language module to be used with C++ that rotate.docxWrite a short assembly language module to be used with C++ that rotate.docx
Write a short assembly language module to be used with C++ that rotate.docxdrosa1
 
Write a short essay- between 400 and 500 words- responding to the assi.docx
Write a short essay- between 400 and 500 words- responding to the assi.docxWrite a short essay- between 400 and 500 words- responding to the assi.docx
Write a short essay- between 400 and 500 words- responding to the assi.docxdrosa1
 
Write a SELECT statement that returns the LastName and JobTitle of eac.docx
Write a SELECT statement that returns the LastName and JobTitle of eac.docxWrite a SELECT statement that returns the LastName and JobTitle of eac.docx
Write a SELECT statement that returns the LastName and JobTitle of eac.docxdrosa1
 
Write a recursive C function that counts the number of vowels in a str.docx
Write a recursive C function that counts the number of vowels in a str.docxWrite a recursive C function that counts the number of vowels in a str.docx
Write a recursive C function that counts the number of vowels in a str.docxdrosa1
 
Write a routine to reconstruct the shortest paths from the algorithm i.docx
Write a routine to reconstruct the shortest paths from the algorithm i.docxWrite a routine to reconstruct the shortest paths from the algorithm i.docx
Write a routine to reconstruct the shortest paths from the algorithm i.docxdrosa1
 
Write a program that uses a dynamic array that contains 5 items of dou.docx
Write a program that uses a dynamic array that contains 5 items of dou.docxWrite a program that uses a dynamic array that contains 5 items of dou.docx
Write a program that uses a dynamic array that contains 5 items of dou.docxdrosa1
 
Write a recursive function to convert a character string of digits to.docx
Write a recursive function to convert a character string of digits to.docxWrite a recursive function to convert a character string of digits to.docx
Write a recursive function to convert a character string of digits to.docxdrosa1
 

More Related Content

More from drosa1

Write a query to display the customer last name and city for all custo.docx
Write a query to display the customer last name and city for all custo.docxWrite a query to display the customer last name and city for all custo.docx
Write a query to display the customer last name and city for all custo.docxdrosa1
 
write a program that reads package weights and calculate the post fee.docx
write a program that reads package weights and calculate the post fee.docxwrite a program that reads package weights and calculate the post fee.docx
write a program that reads package weights and calculate the post fee.docxdrosa1
 
Write a program that takes an input of n and prints the numbers from 1.docx
Write a program that takes an input of n and prints the numbers from 1.docxWrite a program that takes an input of n and prints the numbers from 1.docx
Write a program that takes an input of n and prints the numbers from 1.docxdrosa1
 
Write a program to compute the volume V of a cylinder of radius r and (1).docx
Write a program to compute the volume V of a cylinder of radius r and (1).docxWrite a program to compute the volume V of a cylinder of radius r and (1).docx
Write a program to compute the volume V of a cylinder of radius r and (1).docxdrosa1
 
Write a program in assembly language that will test PIN #0 of PORTA to.docx
Write a program in assembly language that will test PIN #0 of PORTA to.docxWrite a program in assembly language that will test PIN #0 of PORTA to.docx
Write a program in assembly language that will test PIN #0 of PORTA to.docxdrosa1
 
Write a program that uses a dynamic array that contains 5 items of dou (1).docx
Write a program that uses a dynamic array that contains 5 items of dou (1).docxWrite a program that uses a dynamic array that contains 5 items of dou (1).docx
Write a program that uses a dynamic array that contains 5 items of dou (1).docxdrosa1
 
Write a program that calculates the final value of a ten year- $10-000 (1).docx
Write a program that calculates the final value of a ten year- $10-000 (1).docxWrite a program that calculates the final value of a ten year- $10-000 (1).docx
Write a program that calculates the final value of a ten year- $10-000 (1).docxdrosa1
 
Write a program that finds the temperature- as an integer - that is th.docx
Write a program that finds the temperature- as an integer - that is th.docxWrite a program that finds the temperature- as an integer - that is th.docx
Write a program that finds the temperature- as an integer - that is th.docxdrosa1
 
Write a python program that opens the career-txt file that is included.docx
Write a python program that opens the career-txt file that is included.docxWrite a python program that opens the career-txt file that is included.docx
Write a python program that opens the career-txt file that is included.docxdrosa1
 
Write a program that contains and utilizes a function called haltNum(i.docx
Write a program that contains and utilizes a function called haltNum(i.docxWrite a program that contains and utilizes a function called haltNum(i.docx
Write a program that contains and utilizes a function called haltNum(i.docxdrosa1
 
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docxWrite a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docxdrosa1
 
write a program to calculate the average of six number input by the us.docx
write a program to calculate the average of six number input by the us.docxwrite a program to calculate the average of six number input by the us.docx
write a program to calculate the average of six number input by the us.docxdrosa1
 
Write a program that uses the DrawingPanel to produces the following f.docx
Write a program that uses the DrawingPanel to produces the following f.docxWrite a program that uses the DrawingPanel to produces the following f.docx
Write a program that uses the DrawingPanel to produces the following f.docxdrosa1
 
Write a program in assembly language 8086 not 8085 to find the number.docx
Write a program in assembly language 8086 not 8085 to find the number.docxWrite a program in assembly language 8086 not 8085 to find the number.docx
Write a program in assembly language 8086 not 8085 to find the number.docxdrosa1
 
write a mips code which pop-ups a confirmation dialog which have yes o.docx
write a mips code which pop-ups a confirmation dialog which have yes o.docxwrite a mips code which pop-ups a confirmation dialog which have yes o.docx
write a mips code which pop-ups a confirmation dialog which have yes o.docxdrosa1
 
Write a program in (C or C++ or Java or python) to capture the center.docx
Write a program in (C or C++ or Java or python) to capture the center.docxWrite a program in (C or C++ or Java or python) to capture the center.docx
Write a program in (C or C++ or Java or python) to capture the center.docxdrosa1
 
write a new equation of the line in slope intercept form parallel to e.docx
write a new equation of the line in slope intercept form parallel to e.docxwrite a new equation of the line in slope intercept form parallel to e.docx
write a new equation of the line in slope intercept form parallel to e.docxdrosa1
 
Write a program file_max-c that reads a set of integer numbers from a.docx
Write a program file_max-c that reads a set of integer numbers from a.docxWrite a program file_max-c that reads a set of integer numbers from a.docx
Write a program file_max-c that reads a set of integer numbers from a.docxdrosa1
 
Write a PHP function (write the function only) to dynamically create a.docx
Write a PHP function (write the function only) to dynamically create a.docxWrite a PHP function (write the function only) to dynamically create a.docx
Write a PHP function (write the function only) to dynamically create a.docxdrosa1
 
Write a PASCAL program to compare two integers entered from the keyboa.docx
Write a PASCAL program to compare two integers entered from the keyboa.docxWrite a PASCAL program to compare two integers entered from the keyboa.docx
Write a PASCAL program to compare two integers entered from the keyboa.docxdrosa1
 

More from drosa1 (20)

Write a query to display the customer last name and city for all custo.docx
Write a query to display the customer last name and city for all custo.docxWrite a query to display the customer last name and city for all custo.docx
Write a query to display the customer last name and city for all custo.docx
 
write a program that reads package weights and calculate the post fee.docx
write a program that reads package weights and calculate the post fee.docxwrite a program that reads package weights and calculate the post fee.docx
write a program that reads package weights and calculate the post fee.docx
 
Write a program that takes an input of n and prints the numbers from 1.docx
Write a program that takes an input of n and prints the numbers from 1.docxWrite a program that takes an input of n and prints the numbers from 1.docx
Write a program that takes an input of n and prints the numbers from 1.docx
 
Write a program to compute the volume V of a cylinder of radius r and (1).docx
Write a program to compute the volume V of a cylinder of radius r and (1).docxWrite a program to compute the volume V of a cylinder of radius r and (1).docx
Write a program to compute the volume V of a cylinder of radius r and (1).docx
 
Write a program in assembly language that will test PIN #0 of PORTA to.docx
Write a program in assembly language that will test PIN #0 of PORTA to.docxWrite a program in assembly language that will test PIN #0 of PORTA to.docx
Write a program in assembly language that will test PIN #0 of PORTA to.docx
 
Write a program that uses a dynamic array that contains 5 items of dou (1).docx
Write a program that uses a dynamic array that contains 5 items of dou (1).docxWrite a program that uses a dynamic array that contains 5 items of dou (1).docx
Write a program that uses a dynamic array that contains 5 items of dou (1).docx
 
Write a program that calculates the final value of a ten year- $10-000 (1).docx
Write a program that calculates the final value of a ten year- $10-000 (1).docxWrite a program that calculates the final value of a ten year- $10-000 (1).docx
Write a program that calculates the final value of a ten year- $10-000 (1).docx
 
Write a program that finds the temperature- as an integer - that is th.docx
Write a program that finds the temperature- as an integer - that is th.docxWrite a program that finds the temperature- as an integer - that is th.docx
Write a program that finds the temperature- as an integer - that is th.docx
 
Write a python program that opens the career-txt file that is included.docx
Write a python program that opens the career-txt file that is included.docxWrite a python program that opens the career-txt file that is included.docx
Write a python program that opens the career-txt file that is included.docx
 
Write a program that contains and utilizes a function called haltNum(i.docx
Write a program that contains and utilizes a function called haltNum(i.docxWrite a program that contains and utilizes a function called haltNum(i.docx
Write a program that contains and utilizes a function called haltNum(i.docx
 
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docxWrite a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
 
write a program to calculate the average of six number input by the us.docx
write a program to calculate the average of six number input by the us.docxwrite a program to calculate the average of six number input by the us.docx
write a program to calculate the average of six number input by the us.docx
 
Write a program that uses the DrawingPanel to produces the following f.docx
Write a program that uses the DrawingPanel to produces the following f.docxWrite a program that uses the DrawingPanel to produces the following f.docx
Write a program that uses the DrawingPanel to produces the following f.docx
 
Write a program in assembly language 8086 not 8085 to find the number.docx
Write a program in assembly language 8086 not 8085 to find the number.docxWrite a program in assembly language 8086 not 8085 to find the number.docx
Write a program in assembly language 8086 not 8085 to find the number.docx
 
write a mips code which pop-ups a confirmation dialog which have yes o.docx
write a mips code which pop-ups a confirmation dialog which have yes o.docxwrite a mips code which pop-ups a confirmation dialog which have yes o.docx
write a mips code which pop-ups a confirmation dialog which have yes o.docx
 
Write a program in (C or C++ or Java or python) to capture the center.docx
Write a program in (C or C++ or Java or python) to capture the center.docxWrite a program in (C or C++ or Java or python) to capture the center.docx
Write a program in (C or C++ or Java or python) to capture the center.docx
 
write a new equation of the line in slope intercept form parallel to e.docx
write a new equation of the line in slope intercept form parallel to e.docxwrite a new equation of the line in slope intercept form parallel to e.docx
write a new equation of the line in slope intercept form parallel to e.docx
 
Write a program file_max-c that reads a set of integer numbers from a.docx
Write a program file_max-c that reads a set of integer numbers from a.docxWrite a program file_max-c that reads a set of integer numbers from a.docx
Write a program file_max-c that reads a set of integer numbers from a.docx
 
Write a PHP function (write the function only) to dynamically create a.docx
Write a PHP function (write the function only) to dynamically create a.docxWrite a PHP function (write the function only) to dynamically create a.docx
Write a PHP function (write the function only) to dynamically create a.docx
 
Write a PASCAL program to compare two integers entered from the keyboa.docx
Write a PASCAL program to compare two integers entered from the keyboa.docxWrite a PASCAL program to compare two integers entered from the keyboa.docx
Write a PASCAL program to compare two integers entered from the keyboa.docx
 

Recently uploaded

Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with ExamplesBayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with ExamplesTushar Tank
 
2.20.24 The March on Washington for Jobs and Freedom.pptx
2.20.24 The March on Washington for Jobs and Freedom.pptx2.20.24 The March on Washington for Jobs and Freedom.pptx
2.20.24 The March on Washington for Jobs and Freedom.pptxMaryPotorti1
 
UniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tourUniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tourUSC_Library
 
D.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdfD.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdfSUMIT TIWARI
 
The Ministry of Utmost Happiness by Arundhati Roy
The Ministry of Utmost Happiness by Arundhati RoyThe Ministry of Utmost Happiness by Arundhati Roy
The Ministry of Utmost Happiness by Arundhati RoyTrushali Dodiya
 
Evaluation and management of patients with Dyspepsia.pptx
Evaluation and management of patients with Dyspepsia.pptxEvaluation and management of patients with Dyspepsia.pptx
Evaluation and management of patients with Dyspepsia.pptxgarvitnanecha
 
Chromatography-Gas chromatography-Principle
Chromatography-Gas chromatography-PrincipleChromatography-Gas chromatography-Principle
Chromatography-Gas chromatography-Principleblessipriyanka
 
Data Modeling - Entity Relationship Diagrams-1.pdf
Data Modeling - Entity Relationship Diagrams-1.pdfData Modeling - Entity Relationship Diagrams-1.pdf
Data Modeling - Entity Relationship Diagrams-1.pdfChristalin Nelson
 
catch-up-friday-ARALING PNLIPUNAN SOCIAL JUSTICE AND HUMAN RIGHTS
catch-up-friday-ARALING PNLIPUNAN SOCIAL JUSTICE AND HUMAN RIGHTScatch-up-friday-ARALING PNLIPUNAN SOCIAL JUSTICE AND HUMAN RIGHTS
catch-up-friday-ARALING PNLIPUNAN SOCIAL JUSTICE AND HUMAN RIGHTSCarlaNicolas7
 
EDL 290F Week 1 - Meet Me at the Start Line.pdf
EDL 290F Week 1 - Meet Me at the Start Line.pdfEDL 290F Week 1 - Meet Me at the Start Line.pdf
EDL 290F Week 1 - Meet Me at the Start Line.pdfElizabeth Walsh
 
Food Web SlideShare for Ecology Notes Quiz in Canvas
Food Web SlideShare for Ecology Notes Quiz in CanvasFood Web SlideShare for Ecology Notes Quiz in Canvas
Food Web SlideShare for Ecology Notes Quiz in CanvasAlexandraSwartzwelde
 
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATIONUNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATIONSayali Powar
 
ACTIVIDAD DE CLASE No 1 - SOPA DE LETRAS
ACTIVIDAD DE CLASE No 1 - SOPA DE LETRASACTIVIDAD DE CLASE No 1 - SOPA DE LETRAS
ACTIVIDAD DE CLASE No 1 - SOPA DE LETRASMaria Lucia Céspedes
 
Overview of Databases and Data Modelling-1.pdf
Overview of Databases and Data Modelling-1.pdfOverview of Databases and Data Modelling-1.pdf
Overview of Databases and Data Modelling-1.pdfChristalin Nelson
 
Grantseeking Solo- Securing Awards with Limited Staff PDF.pdf
Grantseeking Solo- Securing Awards with Limited Staff  PDF.pdfGrantseeking Solo- Securing Awards with Limited Staff  PDF.pdf
Grantseeking Solo- Securing Awards with Limited Staff PDF.pdfTechSoup
 
LIPIDS UNIT ONE BIOMOLECULE PRESENTATION
LIPIDS UNIT ONE BIOMOLECULE PRESENTATIONLIPIDS UNIT ONE BIOMOLECULE PRESENTATION
LIPIDS UNIT ONE BIOMOLECULE PRESENTATIONSayali Powar
 
DISCOURSE: TEXT AS CONNECTED DISCOURSE
DISCOURSE:   TEXT AS CONNECTED DISCOURSEDISCOURSE:   TEXT AS CONNECTED DISCOURSE
DISCOURSE: TEXT AS CONNECTED DISCOURSEMYDA ANGELICA SUAN
 

Recently uploaded (20)

Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with ExamplesBayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
 
2.20.24 The March on Washington for Jobs and Freedom.pptx
2.20.24 The March on Washington for Jobs and Freedom.pptx2.20.24 The March on Washington for Jobs and Freedom.pptx
2.20.24 The March on Washington for Jobs and Freedom.pptx
 
UniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tourUniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tour
 
D.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdfD.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdf
 
The Ministry of Utmost Happiness by Arundhati Roy
The Ministry of Utmost Happiness by Arundhati RoyThe Ministry of Utmost Happiness by Arundhati Roy
The Ministry of Utmost Happiness by Arundhati Roy
 
Evaluation and management of patients with Dyspepsia.pptx
Evaluation and management of patients with Dyspepsia.pptxEvaluation and management of patients with Dyspepsia.pptx
Evaluation and management of patients with Dyspepsia.pptx
 
Chromatography-Gas chromatography-Principle
Chromatography-Gas chromatography-PrincipleChromatography-Gas chromatography-Principle
Chromatography-Gas chromatography-Principle
 
first section physiology laboratory.pptx
first section physiology laboratory.pptxfirst section physiology laboratory.pptx
first section physiology laboratory.pptx
 
Data Modeling - Entity Relationship Diagrams-1.pdf
Data Modeling - Entity Relationship Diagrams-1.pdfData Modeling - Entity Relationship Diagrams-1.pdf
Data Modeling - Entity Relationship Diagrams-1.pdf
 
catch-up-friday-ARALING PNLIPUNAN SOCIAL JUSTICE AND HUMAN RIGHTS
catch-up-friday-ARALING PNLIPUNAN SOCIAL JUSTICE AND HUMAN RIGHTScatch-up-friday-ARALING PNLIPUNAN SOCIAL JUSTICE AND HUMAN RIGHTS
catch-up-friday-ARALING PNLIPUNAN SOCIAL JUSTICE AND HUMAN RIGHTS
 
Capter 5 Climate of Ethiopia and the Horn GeES 1011.pdf
Capter 5 Climate of Ethiopia and the Horn GeES 1011.pdfCapter 5 Climate of Ethiopia and the Horn GeES 1011.pdf
Capter 5 Climate of Ethiopia and the Horn GeES 1011.pdf
 
EDL 290F Week 1 - Meet Me at the Start Line.pdf
EDL 290F Week 1 - Meet Me at the Start Line.pdfEDL 290F Week 1 - Meet Me at the Start Line.pdf
EDL 290F Week 1 - Meet Me at the Start Line.pdf
 
Food Web SlideShare for Ecology Notes Quiz in Canvas
Food Web SlideShare for Ecology Notes Quiz in CanvasFood Web SlideShare for Ecology Notes Quiz in Canvas
Food Web SlideShare for Ecology Notes Quiz in Canvas
 
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATIONUNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
UNIT 1 BIOMOLECULE_CARBOHYDRATES PRESENTATION
 
ACTIVIDAD DE CLASE No 1 - SOPA DE LETRAS
ACTIVIDAD DE CLASE No 1 - SOPA DE LETRASACTIVIDAD DE CLASE No 1 - SOPA DE LETRAS
ACTIVIDAD DE CLASE No 1 - SOPA DE LETRAS
 
Overview of Databases and Data Modelling-1.pdf
Overview of Databases and Data Modelling-1.pdfOverview of Databases and Data Modelling-1.pdf
Overview of Databases and Data Modelling-1.pdf
 
Caldecott Medal Book Winners and Media Used
Caldecott Medal Book Winners and Media UsedCaldecott Medal Book Winners and Media Used
Caldecott Medal Book Winners and Media Used
 
Grantseeking Solo- Securing Awards with Limited Staff PDF.pdf
Grantseeking Solo- Securing Awards with Limited Staff  PDF.pdfGrantseeking Solo- Securing Awards with Limited Staff  PDF.pdf
Grantseeking Solo- Securing Awards with Limited Staff PDF.pdf
 
LIPIDS UNIT ONE BIOMOLECULE PRESENTATION
LIPIDS UNIT ONE BIOMOLECULE PRESENTATIONLIPIDS UNIT ONE BIOMOLECULE PRESENTATION
LIPIDS UNIT ONE BIOMOLECULE PRESENTATION
 
DISCOURSE: TEXT AS CONNECTED DISCOURSE
DISCOURSE:   TEXT AS CONNECTED DISCOURSEDISCOURSE:   TEXT AS CONNECTED DISCOURSE
DISCOURSE: TEXT AS CONNECTED DISCOURSE
 

Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docx

  • 1. Write a SIMPLE java program to print out the numbers from 100 to 1, with the following conditions: If the number ends in 4, don't print it; instead, print "hello" If the number is a multiple of 6, don't print it; instead print "world" If the number is both a multiple of 6 and ends in 4, don't print it, instead print "hello world" Solution import java.util.Scanner; class Helloworld { public static void main(String []args) { Scanner input = new Scanner(System.in); int num=100; System.out.println("Input your number and press enter: "); if(num== 4) { System.out.println("Hello"); } else if(num==6) { System.out.println("world"); } else { System.out.println("Hello world"); } } }