How can I create a Java Program that counts down from 40 to 0 printing only the odd numbers and excl
The program has to exclude 3 and 33, and must use a continue and if statement??
I am able to create a program using the for statement, but not a while statement. Please help.
import java.util.*;
public class loop
{
public static void main (String[] args)
int count = 39;
while (count > 0)
if (count = 3)
exclude from statement
if count = 33
exclude from statement
System.out.print(count + " ");
count--
}
How can I create a Java Program that counts down from 40 to 0 printing only the odd numbers and excluding 3?
/*
He forgot that you need to use a continue statement...
*/
public class MyCounter {
聽public static void main(String args[]) {
聽聽int count = 40;
聽聽while (--count > 0) {
聽聽聽聽if (count % 2 == 0 || count == 33 || count == 3) continue;
聽聽聽聽else System.out.print(count + " ");
聽聽}
聽}
}
How can I create a Java Program that counts down from 40 to 0 printing only the odd numbers and excluding 3?
Easy. But first, names for class are by convention started with a Cap, variables are lowerCase humpback notation.
=================
/**
*
* @author blessed_thang
*/
public class OddCounter {
public static void main(String args[]) {
int topNum = 40;
while (topNum > 0) {
if (topNum % 2 != 0 && topNum != 33 && topNum != 3) {
System.out.print(topNum + " ");
}
topNum--;
}
}
}
- C++......................?
- is there a less complicated c++ compiler than microsoft express 2008? i found it to complicated and hav found no other free program to make a fps. a t..
- C++???????
- I am trying to make a tic tac toe game for c++ but i dont know how to use an array to make the board. also after i make the board hiw do i code it so ..
- C++???????????????
- I HAVE NO IDEA WHAT C++ IS? and i have an exam tomorrow. I dont understand 1. character set 2.tokens. i also have the for statement program, if stat..
- C++..........................?
- where i find the best c++ programing books.C++..........................?AT www.esnips.com/C++..........................?Try doing a search. OReilly t..
- C++????????
- i need to know a simple program to concat two strings without using strcat inside operator overloading.plz help me with a program..............C++????..
- ...................c++?
- How would I create a program that that displays the sum of a sales amount in each of 4 regions, during a 3 month period, which would also display the ..
- "Smitfraud-C. Toolbar888&..
- I am a webmaster, and I am trying to build my website, but my computer keeps acting weird and seems to be going into random hybernation for no reason ..
- C programme...?
- I wrote a programme of calculator in C language. And it has two or three error so pl do correct them. And send me correct answer. Prog. is: #includest..
- C programme...?
- I wrote a programme of calculator in C language. And it has two or three error so pl do correct them. And send me correct answer. Prog. is: #includest..
- C programme...?
- I wrote a programme of calculator in C language. And it has two or three error so pl do correct them. And send me correct answer. Prog. is: #includest..
