is there any other way to write this code if (quantity>=5) { System.out.println(“Congrats!! You get a discount of 5%.”); } else { System.out.println(“you can avail a discount of 5% when you make a purchase of 5 items.”); } Can Smith
please help me. i need a code.in our ACTIVITY this is the question to do.. (triangle printing program) write an application that displays the following patterns separately, one below the other .use “for loops” to generate the patterns. all asterisks(*) should be printed by a single statements of the form System.out.println(*); w/c causes the asterisks to print side by side .A statement of the form System.out.print(‘ ‘); can be used to display a space for the last two patterns. there should be no other output statements in the program. [hint: the last two patterns requires each line begin with an appropriate number of blank spaces]
We can use Io.scanners input ones but i have written the code as normal while loop .Hope this helps you 🙂 If you want to change the pswd then it shows its a wrong pin.It’s a basic programming in while loop.
java is tooooooo!!!!!! cooooolll and logiiiic ful
help me make a source code :))
moodunga
is there any other way to write this code
if (quantity>=5)
{
System.out.println(“Congrats!! You get a discount of 5%.”);
}
else
{
System.out.println(“you can avail a discount of 5% when you make a purchase of 5 items.”);
}
Can Smith
help me make a code with the help of do while, for loop and array
public class loopexample
{
public static void main(String args[])
{
int[] a={ 1,2,3,4,5,6,7,8,};
System.out.print(“using do while”);
int i=0;
int average1=0;
do
{
average1+=a[i];
i++;
}
while(i<a.length); system.out.println(“the=”” average=”” of=”” the=”” array”+average1);=”” system.out.print(“using=”” for=”” loop”);=”” int=”” average2=”0;” for(i=”0;i<a.length;i++)” {=”” average2+=”a[i];” }=”” system.out.println(“the=”” average=”” of=”” the=”” array”+average2);=”” }=”” }=””>
please help me. i need a code.in our ACTIVITY this is the question to do..
(triangle printing program) write an application that displays the following patterns separately, one below the other .use “for loops” to generate the patterns. all asterisks(*) should be printed by a single statements of the form System.out.println(*); w/c causes the asterisks to print side by side .A statement of the form System.out.print(‘ ‘); can be used to display a space for the last two patterns. there should be no other output statements in the program. [hint: the last two patterns requires each line begin with an appropriate number of blank spaces]
a)
*
**
***
****
*****
******
*******
********
*********
**********
b)
**********
*********
********
*******
******
*****
****
***
**
*
c)
**********
*********
********
*******
******
*****
****
***
**
*
d)
*
**
***
****
*****
******
*******
********
*********
**********
class Star {
public static void main(String agrs[]) {
System.out.println(“The Pattern is”);
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (j <= i) {
System.out.print(” *”);
} else {
System.out.print(” “);
}
}
System.out.println();
}
}
}
output:
*
**
***
****
*****
please help me to write a program in java that impliments how an ATM works when authenticating a user(use while loop)
We can use Io.scanners input ones but i have written the code as normal while loop .Hope this helps you 🙂 If you want to change the pswd then it shows its a wrong pin.It’s a basic programming in while loop.
public class DoWhile {
public static void main(String[] args) {
String name = “john”;
String pswd = “2999”;
do{
System.out.println(“Enter the password :” +pswd);
if(pswd==”2999″){
System.out.println( “Enter the amount”);
System.out.println(“draw the money”);
System.out.println(“withdrawl money”);
System.out.println(“Reciept”);
}else
System.out.println(“Wrong pin number”);
break;
}while(name==”john”);
}
}
Please help me to answer the question:
. Write an input validation loop that asks the user to enter a number in the range of
10 through 24.
please give me some code in java . using do while ,,
this is the output:
*
**
***
****
*****
public class pyramid
{
public static void main(String args[])
{
int i=0;
while(i<=5)
{
int r=0;
while(r<i) {=”” system.out.print(“*”);=”” r++;=”” }=”” system.out.println();=”” i++;=”” }=”” }=”” }=””>
package mypackage2;
public class pyramid {
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
System.out.print(“*”);
}
System.out.println();
}
}
}
Well this kind of output only possible through for loop .This is code for do-while .Hope this helps you 🙂
public class DoWhile {
public static void main(String[] args) {
short c = 0;
do{
System.out.println(“*”);
System.out.println(“**”);
System.out.println(“***”);
System.out.println(“****”);
System.out.println(“*****”);
c++;
}while(c<1);
}
}
class Subh
{
public static void main(String arg[])
{
int i,j,n=5;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(“*”);
}
System.out.println();
}
}
}
for more programs contact me at
please help me
(Find the smallest n such that n^2 > 12,000) Use a while loop to find the smallest
integer n such that n^2 is greater than 12,000
please help me how to get this:
1
12
123
1234
12345
plzzz….give me some code in java using while loop
nd the o/p will be
*
**
***
****
*****
class pattern1
{
public void print()
{
for (int i=1;i<=5;i++)
{
for (int j=1;j<=i;j++)
{
System.out.print(” * “);
}
System.out.println();
}
}
}
public class DoWhile {
public static void main(String[] args) {
short c = 0;
do{
System.out.println(“*”);
System.out.println(“**”);
System.out.println(“***”);
System.out.println(“****”);
System.out.println(“*****”);
c++;
}while(c<1);
}
}
public class While {
public static void main(String[] args) {
short i = 0;
while(i<1){
System.out.println(“*”);
System.out.println(“**”);
System.out.println(“***”);
System.out.println(“****”);
System.out.println(“*****”);
System.out.println(“******”);
i++;
}
}
}
how to create pyramid that the user must input a number for example i input 5 and it will be like this
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
or like this
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
class ssa
{
public static void main(String arg[])
{
int i,j,n=5;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
More details contact me
public class hello
{
public static void main (String arg[])
{
int i=1;
while (i<=10)
System.out.println(“Hello World”);
i++;
}
}
can any body help me in this program.. i am new to Java.. this program creates continuous loop.. plz help.