For Loop
For loop executes group of Java statements as long as the boolean condition evaluates to true.
For loop combines three elements which we generally use: initialization statement, boolean expression and increment or decrement statement.
For loop syntax
for( ; ; ){
;
}
The initialization statement is executed before the loop starts. It is generally used to initialize the loop variable.
Condition statement is evaluated before each time the block of statements are executed. Block of statements are executed only if the boolean condition evaluates to true.
Statement is executed after the loop body is done. Generally it is being used to increment or decrement the loop variable.
Following example shows use of simple for loop.
for(int i=0 ; i < 5 ; i++)
{
System.out.println("i is : " + i);
}
It is possible to initialize multiple variable in the initialization block of the for loop by separating it by comma as given in the below example.
for(int i=0, j =5 ; i < 5 ; i++)
It is also possible to have more than one increment or decrement section as well as given below.
for(int i=0; i < 5 ; i++, j--)
However it is not possible to include declaration and initialization in the initialization block of the for loop.
Also, having multiple conditions separated by comma also generates the compiler error. However, we can include multiple condition with && and || logical operators.
* *
*$* *$*
*$*$* *$*$*
*$* *$*$*$*
* *$*$*
*$*
*
public class A
{
public static void main(String[]args)
{
System.out.println(“* *”);
System.out.println(” “);
System.out.println(“*$* *$*);
System.out.println(” “);
System.out.println(“*$*$* *$*$*”);
System.out.println(” “);
System.out.println(“*$* *$*$*$*”);
System.out.println(” “);
System.out.println(“* *$*$*”);
System.out.println(“*$*”);
System.out.println(“*”);
}
}
A
BC
DEF
GHIJ
KLMNO
PQRSTU
class Print
{
void cal()
{
int a=97;
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
char ch=(char)a;
system.out.print(ch);
a=a+1;
}
System.out.println();
}
}
class gen_loop2
{
public static void main (String[] args)
{
int xx = 65;
for(int i=1; i<= 10;i++)
{
for(int j=1; j <= i ; j++)
{
char x = (char)xx;
xx = xx+1;
System.out.print(x);
}
System.out.println();
}
}
}
class star
{
public static void main(String arg[])
{
int i,j;
for(i=0;i<6;i++)
{
for(j=0;j<i;j++) {=”” system.out.print(“=”” *”);=”” }=”” system.out.println();=”” }=”” }=”” }=”” output:-=”” *=”” **=”” ***=”” ****=”” *****=””>
a to z print ex- a, bc, cde, efge,….
class LetterPyramid
{ public static void main()
{ char c;
int i,j;
for(i=65;i<=90;i++)
{
for(j=0;j<(i-64);j++)
{c=(char)i;
System.out.print(c);
}
System.out.println();
}
}
}
for (int c = 65, j = 1; c < ‘V’; j++) {
for (int i = 1; i <= j; c++, i++)
System.out.print ((char)c);
System.out.println ()
}
public class ForExample {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
char ch=’A’;
int count=0;
for(int i=0;i<6;i++){
for(int j=0;j<=i;j++){
System.out.print(ch++);
count++;
}
System.out.print(“
“);
}
System.out.println(count);
}
}
***********
***** *****
**** ****
*** ***
** **
* *
[code]
class Print
{
public static void main(String args[])
{
int i,j;
for(i=5;i>=1;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(” *”);
}
System.out.println();
}
}
}
[/code]
it writes infinite number of *
because in the first for loop i=5 and test i>=1 and update is i++
it means i will increase untill the test fail
but test will not fail forever
class Print
{
public static void main(String args[])
{
int i,j;
for(i=1;i<=5;i++) // it is not for(i=5;i>=1;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(” *”);
}
System.out.println(“by elvinson”);
System.out.println();
}
}
}
class stars
{
public static void main (String args[])
{
System.out.println(“***********”);
System.out.println(“***** *****”);
System.out.println(“**** ****”);
System.out.println(“*** ***”);
System.out.println(“** **”);
System.out.println(“* *”);
}
}
class Tanha{
public static void main(String rgs[]){
System.out.println(“A
BC
DEF
DEF
GHIJ
KLMNO
PQRSTU
VWXYZ”);
}
}
pleas help me what is doing on dis “
Create a simple program using a loop, the program will the user to input a base and the exponent, and your frogram will output its total,
a.Create a program using the following method:
i.Name, Age, Height and Weight
ii.Class name is SecretInfo
iii.Provide parameters to each method.
public class answer{
public static void main(String[] args) {
javax.swing.JOptionPane.showInputDialog(“what’s your name?”);
javax.swing.JOptionPane.showInputDialog(“what’s your age?”);
javax.swing.JOptionPane.showInputDialog(“what’s your height?);
javax.swing.JOptionPane.showInputDialog(“what’s your weight”);
}
}
* * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
class star
{
public static void main(String args[])
{
int i,j;
for(i=1;i<6;i++)
{
for(j=i;j<6;j++)
{
System.out.print(” *”);
}
System.out.println();
}
}
}
class starr{
public static void main(String… df){
for(int i=0;i<7;i++){
for(int j=i;j<7;j++)
{
System.out.print(“*”);
}
System.out.println();
}
}
}
1 1
2 2
3 3
4 4
5
int i=5; // input accept
for(int j=1;j<=i;j++){
for (int k=j;k<=i;k++){ // cut it for 2 times if you just want two columns
System.out.print(j);
System.out.print( ” “);
}
System.out.println();
}
for loop? anu yan lge minus 1?
class P
{
public static void main(String args[])
{
int i,j,p=5;
for(i=1;i<=4;i++)
{
for(j=0;j<=1;j++)
{
System.out.print(” “+i);
}
System.out.println();
}
System.out.println(” “+p);
}}
CHECK THIS CODING
class P
{
public static void main(String args[])
{
int i,j,p=5;
for(i=1;i<=4;i++)
{
for(j=0;j<=1;j++)
{
System.out.print(” “+i);
}
System.out.println();
}
System.out.println(” “+p);
}}
Write a program that will determine if the average of 10 inputted numbers is greater than the largest number in the group.
Please ASAP.
you can use two “FOR” loops for this problem to solve………
//same as your
class anonymos{
public static void main(String… df){
int jk=7;
for(int i=0;i<=6;i++){
for(int j=0;j<=1;j++){
System.out.print(” “+i);
}
System.out.println();
}
System.out.print(” “+jk);
}
}
help me to solve this problem:
1/1+2 + 1/1+2+3 + 1/1+2+3+4 +.. .. .. + n/1+2+3+.. ..+(n+1)
help me to solve this problem:
1/1+2 + 1/1+2+3 + 1/1+2+3+4 +.. .. .. + n/1+2+3+.. ..+(n+1)
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
*
* *
* * *
* * * *
class star{
public static void main(String… df){
for(int i=0; i<5;i++){
for(int j=0;j<=i;j++){
System.out.print(“*”);
}
System.out.println();
}
}
}
class Print
{
public static void main(String args[])
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
System.out.println(” *”);
System.out.print(” by elvinson”);
}
System.out.println();
}
}
OUTPUT
*
**
***
****
*****
}
hoe to print a sunny number(if 1 is added to that number, its square root results a whole number)
12345654321
12345 54321
1234 4321
123 321
12 21
1 1
What is the solution
class P
{
public static void main(String args[])
{
int i,j,p=5;
for(i=1;i<=4;i++)
{
for(j=0;j<=1;j++)
{
System.out.print(” “+i);
}
System.out.println();
}
System.out.println(” “+p);
}}
a a
ab ba
abccba
543210
43210
3210
210
10
0
543210
43210
3210
210
10
0
public class Pyramid1
{
public static void main(String[] args)
{
for (int i=5;i>=0;i–)
{
for(int j=i; j>=0; j–)
{
System.out.print(j);
}
System.out.println();
}
}
}
Enter an integer:
9
Number is ODD: 9
Multiple of 3 from 1: 3
0
02
024
0246
help me for this program
how can I solve this??
PROBLEM: Write a java program that asks for your name and then display it on a pattern resembling a right triangle.
INPUT: A name (String)
OUTPUT: A right triangle drawn using the characters of the name (String) provided.
Sample Run 1:
Enter Your Name: STEVE
S
ST
STE
STEV
STEVE
Sample Run 2:
Enter Your Name: GOOGLE
G
GO
GOO
GOOG
GOOGL
GOOGLE
String name = “STEVE”;
for(int z = 0 ; z <name.length() ;=”” z=”” ++)=”” {=”” for(int=”” x=”0″ ;=”” x=”” <=”z” ;=”” x=”” ++)=”” {=”” char=”” xx=”name.charAt(x);” system.out.print(xx);=”” }=”” system.out.println(“”);=”” }=””>
nice
String name = “GOOLGE”;
for(int z = 0 ; z<name.length() ;=”” z=”” ++)=”” {=”” for(int=”” x=”0″ ;=”” x=”” <=”z” ;=”” x++)=”” {=”” char=”” xx=”name.charAt(x);” system.out.print(xx);=”” }=”” system.out.println(“”);=”” }=””>
class google{
public static void main(String… df)
{
String s=”GOOGLE”;
System.out.println(“the length of string is : “);
System.out.println(“GOOGLE”.length());
System.out.println();
String s1=s.substring(0,1);
System.out.println(s1);
String s2=s.substring(0,2);
System.out.println(s2);
String s3=s.substring(0,3);
System.out.println(s3);
String s4=s.substring(0,4);
System.out.println(s4);
String s5=s.substring(0,5);
System.out.println(s5);
String s6=s.substring(0,6);
System.out.println(s6);
}
}
char[] google= {‘G’,’O’,’O’,’G’,’L’,’E’};
for(int i=0; i < google.length; i++)
{
for(int j=0; j <= i ; j++)
{
System.out.print(google[j]);
}
System.out.println(“”);
}
import java.util.Scanner;
class a{
public static void main(String args[]){
String name, full=””;
Scanner in = new Scanner(System.in);
System.out.println(“Input Your Name :”);
name = in.nextLine();
for(int x=0; x<name.length();x++){ full=”full” +=”” name.charat(x);=”” system.out.println(full);=”” }=”” }=”” }=””>
import java.util.Scanner;
class a{
public static void main(String args[]){
String name, full=””;
Scanner in = new Scanner(System.in);
System.out.println(“Input Your Name :”);
name = in.nextLine();
for(int x=0; x<name.length();x++){ full=”full” +=”” name.charat(x);=”” system.out.println(full);=”” }=”” }=”” }=””>
import java.util.Scanner;
class a{
public static void main(String args[]){
String name, full=””;
Scanner in = new Scanner(System.in);
System.out.println(“Input Your Name :”);
name = in.nextLine();
for(int x=0; x<name.length();x++){ full=”full” +=”” name.charat(x);=”” system.out.println(full);=”” }=”” }=”” }=””>
1
2 3
4 5 6
7 8 9 10
public class TestUrStuff
{
public static void main(String[] args)
{
int n=3;
int k=0;
for(int i=0;i<=n;i++){
k++;
for(int j=0;j<i;j++) {=”” system.out.print(k+”=”” “);=”” k=”k+1;” }=”” system.out.println(k);=”” }=”” }=”” }=””>
*****
***
*
class name
psvm(s args[])
{
int i=5;
while(i>=1)
{
for(j=1;j<=i;j++)
s.o.p(“*”);
i=i-2;
s.o.pln();
}
}
}
class tanmay{
public static void main(String args[]) {
for(int i=0;i<5;i++){
for(int j=5;j>i;j–){
System.out.print(“*”);
}
System.out.println();
}
}
}
Enter number : (for example 2) 2
Enter number 1: 5
Enter number 2: 5
The sum is: 10
The product is: 25
*
**
***
****
*****
****
***
**
*
public class Pattern
{
public static void main(String args[])
{
int count=1;
for(int i=1;i<=9;i++)
{
for(int j=1;j<=count;j++)
{
System.out.print(“*”);
}
System.out.println();
if(i<5)
{
count=count+1;
}
else
{
count=count-1;
}
}
}
}
class ArrayOne {
public static void main(String args[]) {
for (int i =0 ; i <=5; i++) {
for (int j = 0; j < i; j++) {
System.out.print(“*”);
}
System.out.println();
}
}
}
*
**
***
****
*****
*
**
***
*
**
***
****
*
**
***
****
*****
class ArrayOne {
public static void main(String args[]) {
for (int i = 0; i <= 5; i++) {
for (int j = 0; j < i; j++) {
for (int k = 0; k <= j; k++) {
System.out.print(“*”);
}
System.out.println();
}
}
}
}
1
12
123
1234
12345
123456
1234567
12345678
123456789
class ArrayOne {
public static void main(String args[]) {
for (int i = 1; i <= 9; i++) {
System.out.println();
for (int j = 1; j <= i; j++) {
System.out.print(j);
}
}
System.out.println();
}
}
God bless you on this example and Athmna the help me solve this example and thank you very much..
1)
. Write a for loop that displays every fifth number, zero through 100.
class a2{
public static void main(String args[]){
for(int i = 0; i<=100; i++){
if(i%5==0){
System.out.println(i);
}
}
}
}
12345
1234
123
12
1
reply plss i need know Thank you
class krishna
{
public static void main(String[] args)
{
for(int i=9;i>=0;i–)
{
System.out.println();
for(j=9;j>=i;j–)
{
System.out.println(j);
}
}
System.out.println();
}
}
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)
*
**
***
****
*****
******
*******
********
*********
**********
answer for B option
class Demo1
{
public static void main(String[] args)
{
for(int i=1;i<=10;i++)
{
for(int j=10;j>=i;j–)
{
System.out.printf(“*”)
}
System.out.println();
}
}
}
(Y)
answer for b)
class b{
public static void main(String args[]){
for(int i=1;i<=10;i++){
for(int x=10; x>i; x–)
System.out.print(“*”);
System.out.println(“”);
}
}
}
i am having a large array that i want to sort, that is having 1000000 indexes but i want it to be sorted in a U shape, how do i go about that any one can help me with the algorithm.
i am having a large array that i want to sort, that is having 1000000 indexes but i want it to be sorted in a U shape, how do i go about that any one can help me with the algorithm.
R****R
@R**R*
@@RR**
@@RR**
@R@@R*
R@@@@R
kindly help me for this ^_^
how to make this for loop output 011235813
System.out.println(“011235813”);
This is a fibonacci series
what are the three types of for loop statement that can accept input from user?please help me..tnx!
A number is said to be unique if digits of a number are not repeated in it.
Input : 5890
Output: Unique Number
WAP to accept a number and display the new number after removing all zeros. ASAP plz
import java.util.*;
class remove
{
void display()
{
String n=””,num=””;int l=0;
Scanner sc=new Scanner(System.in);
System.out.print(“\n Enter the number: “);
n=sc.next();
l=n.length();
for(int i=0;i<l;i++) {=”” if(n.charat(i)=””>48&&n.charAt(i)<=57)
{
num=num+(n.charAt(i));
}
}
System.out.print(“The new number after removing zeros =”+num);
}
}
can u give a code for this ?
this will be the output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
i need the code too
int u = 16;
int r[][]= new int [17][17];
for(int i=0;i<r.length ;i++)=”” {=”” for(int=”” t=”0;” t<17;=”” t++)=”” {=”” if=”” (t=”=u)” system.out.print(=”” “1”=”” );=”” else=”” system.out.print(“0″);=”” }=”” u=”u-1;” system.out.println(“”);=”” }=””>
please explain it
please give me a code for this output..
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
int u = 16;
int r[][]= new int [17][17];
for(int i=0;i<r.length ;i++)=”” {=”” for(int=”” t=”0;” t<17;=”” t++)=”” {=”” if=”” (t=”=u)” system.out.print(=”” “1”=”” );=”” else=”” system.out.print(“0″);=”” }=”” u=”u-1;” system.out.println(“”);=”” }=””>
Create a program that will add
numbers from 1 to 10. Use for – loop statement. Show the sum of the
problem.
#include <stdio.h>
#include<conio.h>
void main()
{
int n;
int sum=0;
clrscr();
for(num=1; num<=10; num++)
{
printf(“%4d”, num);
sum=sum+num;
}
printf(“Sum is %d”, sum);
getch();
}
123
654
987
and
123
894
765
plz help me with this pattern
13579
35791
57913
79135
91357
thnx.
public void tript1()
{
int num=1;
for(int i=1;i<=10;i+=2)
{
for(int j=i;j<=10;j+=2)
{
System.out.print(j);
}
for(int k=1;k<num;k=k+2) {=”” system.out.print(k);=”” }num+=”2;” system.out.println();=”” }=”” }=””>
pleas help me what is answer this code
int x=1;
while(x,=5){
for (int y=1;y,x;+){
}
System.out.println(“\n”);
xtt;
}
s=0+3+8+15+24….upto N terms (write program 2 display the sum of the foll.)
Please help me at this pattern
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
Please help me at this pattern
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
class tanmay {
public static void main(String args[]) {
for(int i=0;i<5;i++){
for(int j=5;j>i;j–){
System.out.print(j);
}
System.out.println();
}
}
}
plese help me!!!!!!!!!!!
write a java program to input 20 integers and print all the perfect numbers among integers
import java.util.Scanner;
class demo2{
public static void main(String args[]){
Scanner input_no = new Scanner(System.in);
String numb;
int[] anArray;
anArray = new int[5];
System.out.println(“Input 5 Integers :”);
for(int i=0;i<5;i++){
anArray[i] = Integer.valueOf(input_no.nextLine());
}
for(int i=0;i<5;i++){
int sum=0, x=1;
while(x<anarray[i]){ if(anarray[i]%x=”=0)” sum=”sum+x;” x++;=”” }=”” if(sum=”=anArray[i]){” system.out.println();=”” system.out.print(anarray[i]=”” +=”” “=”” “);=”” }=”” }=”” }=”” }=””>
class demo1{
public static void main(String args[]){
for(int i=0;i<5;i++){
for(int x=5;x>i; x–){
System.out.print(x);
}
System.out.println();
}
}
}
public class Pyramid1
{
public static void main(String[] args)
{
for (int i=1;i<=5;i++)
{
for(int j=5; j>=i; j–)
{
System.out.print(j);
}
System.out.println();
}
}
}
write a program that you input a number and the output is the word of you input the numbers pls help
WHAT IS THE CODE FOR THIS PATTERN?
1+1=2 // if the input is 1
1+2=3 // if the input is 2
1+2+3=6 // if the input 3
1+2+3+4=10 //….
1+2+3+4+5=15 //…..
class pattern
{
void display(int n)
{
int sum=0;
for(int i=1;i<=n;i++)
{
sum=sum+i;
}
System.out.print(“\n The output = “+sum);
}
}
5. Write an input validation loop that asks the user to enter a number in the range of
10 through 24.
6. Write an input validation loop that asks the user to enter ‘Y’, ‘y’, ‘N’, or ‘n’.
kindly help me please/.. 🙁
a)
*
**
***
****
*****
******
*******
********
*********
**********
b)
**********
*********
********
*******
******
*****
****
***
**
*
c)
**********
*********
********
*******
******
*****
****
***
**
*
d)
*
**
***
****
*****
******
*******
********
*********
**********
Write a for loop that displays every fifth number, zero through 100.
Write a program to get five integer numbers from the user and store it into file.
Using Reader and Writer file.
10. Write a program reads the numbers from the previous file and accumulates their
sum.
what is the java cods of this problem:
Create a java program that displays the alphabet listed below using for loop statement
b d f h j l n p r t v x z
how to make this program plz help..
Make a GUI program that would ask the user the number of times the program will ask for a vowel letter of either uppercase or lowercase. The program must display how many times the user keyed in a particular character.
Sample Output:
How many iterations you want? 6
Enter a vowel letter: a
Enter a vowel letter: E
Enter a vowel letter: i
Enter a vowel letter: I
Enter a vowel letter: a
Enter a vowel letter: a
You keyed in lowercase a three (3) time(s).
You keyed in lowercase i one (1) time(s).
You keyed in uppercase E one (1) time(s).
please help me to do a program that has a for loop, nested if, if-else statement
*
* *
* * *
* * * *
How to solve this problem using for loop
???
How can i solve this….
PROBLEM: Create a program that will display the output below using looping
OUTPUT:
12345
1234
123
12
1
I need a java code to print
abc
acb
bac
bca
cab
cba
like that all combination.whatever i given it has to perform all possible combinations.
how to solve this problem
0
12
345
6789
hoe to solve?
0
12
345
6789
1******
12*****
123****
1234***
12345**
123456*
1234567
hi
*
* *
* * *
please solve this problem
*
* *
* * *
solove this problem
will do this in for loop
1
12
123
1234
12345
1234
123
12
1
plz help me how to use for loop for this pattern
*
* *
* * *
* * * *
* * * * *
class Star{
public static void main(String args[]){
String a = “*”;
for(int i=0; i<=5; i++){
System.out.println();
for(int j=1; j<=i; j++){
System.out.print(a);
}
}
}
}
The Human Resources Department of Apex Manufacturing Company wants a report that shows its employees the benefits of saving for retirement. Produce a report that shows 12 predicted retirement account values for each employee—the values if the employee saves 5, 10, or 15 percent of his or her annual salary for 10, 20, 30, or 40 years. Design an application that inputs employees’ names and salaries and outputs the name followed by the 12 predicted account values for each employee. Assume that savings grow at a rate of 8 percent per year.
please help m e huhuuhu
Create a program that will allow the
user to enter 10 temperature and then
find and display average of the temperature
then display the entered temperature
with a remark ” average , above average, and below average”
Temperature<90.1 = Below average
Temperature=90.1 = Average
Temperature>90.1 = Above average
Sample :
——————————————-
enter temperature: 90.1
enter temperature: 90.1
enter temperature: 90.1
enter temperature: 90.1
enter temperature: 90.1
enter temperature: 90.1
enter temperature: 90.1
enter temperature: 90.1
enter temperature: 90.1
enter temperature: 90.1
the average temperature is 90.1
1 temperature: 90.1 Average
2 temperature: 90.1 Average
3 temperature: 90.1 Average
4 temperature: 90.1 Average
5 temperature: 90.1 Average
6 temperature: 90.1 Average
7 temperature: 90.1 Average
8 temperature: 90.1 Average
9 temperature: 90.1 Average
10 temperature: 90.1 Average
the average temperature is 90.1 Average
————————————————————
please help me…
my project..
plese,help me with this pattern
999999999
7777777
55555
333
1
how can i sovle this:
____space_________ *
_________________*$
________________*$*
_______________*$*$
______________*$*$*
_____________*$*$*$
____________*$*$*$*
Output:
1
22
333
4444
55555
and
5
44
333
2222
11111
what your logic to solve this
class Me
{
public static void main(String[] args)
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(i);
}
System.out.println(“”);
}
}
}
Output:
19
17
15
13
11
9
7
5
3
1
0
the output must be odd numbers from 1 to 19
can someone help in this one
output(looping)
Enter the number of steps:5(+1)
The current stepvalue is:6
Enter the number of steps:8(+ the current step value)
The current stepvalue is:14
help….
*****
****
***
**
*
how to javaprogram the StudyloadStatement using Arrays & Forloop |?
#INEEDTHE ANSWER NOW
wow you guys are owesome in programming
make a program that input 2 integer repeatedly…… this is my exam for today 🙁 help pls.. im a begginer in programming
how many mistakes did participant 1 make on interface 1? 5
how many mistakes did participant 2 make on interface 1? 0
how many mistakes did participant 3 make on interface 1? 2
how many mistakes did participant 4 make on interface 1? 4
how many mistakes did participant 5 make on interface 1? 1
how many mistakes did participant 1 make on interface 2? 2
how many mistakes did participant 2 make on interface 2? 3
how many mistakes did participant 3 make on interface 2? 0
how many mistakes did participant 4 make on interface 2? 0
how many mistakes did participant 5 make on interface 2? 1
12 mistakes were made with interface 1
6 mistakes were made with interface 2
Interface 2 seems to be easier to use than interface 1
Could anyone write a for loops program about this, please? Many thanks.
Please Help me in this program*****
Write an GUI application which uses this file.
_____________________________
| textfield |
| button |
| |
|_____________________________|
So you need a button and a textfield. If you click on the button, the value of the textfield will change.
The textfield should show the result of the next expression from the input file.
Goal:
– first click on button -> value of the textfield: “5” (because 3 + 2 == 5)
– second click on button -> value of the textfield: “6” (because 6 * 1 == 6)
– third click on button -> value of the textfield: “NaN” (because 6 / 0 is not a number)
– fourth click on button -> value of the textfield: “5” (because we are finished, so we start from the beginning again)…..
Thank you
public class forever
{
public static void main (String[]args)
{
for (int a=1; a==a; a++)
{
System.out.println(“FOREVER”);
}
}
}
how about this
.
..
..|
..|.
..|..
help me here please
user will input a number
for example he/she input 5
it will print
12345
1234
123
12
1
and it will print
do you want to try again y/n?
if yes it will repeat the program
else if no end of the program
ps.sorry for the grammar, please help me thank you.
using the for loop i want to display this pattern
13579
5739
739
39
9
1******
12*****
123****
1234***
12345**
123456*
1234567
can anyone send me a illustration of how to make a game in java programming
how can i write
1 2 3 4 5 6
2 4 6 8 10 12
3 6 9 12 15 18
4 8 12 16 20 24
5 10 15 20 25 30
Help me with this pattern, please.
1
2 3
3 4 5
4 5 6 7
5 6 7 8 9
how can i generate a table using for loop
Please help!
Write a program that utilizes a loop to read a set of five
floating-point values from user input. Ask the user to enter the values;
then print the following data:
Total
Average
Maximum
Minimum
Interest at 20%
String name= “Chaitu”;
String result = “”;
int length=name.length();
for(int i=0;i<length;i++) {=”” result=”result+name.charAt(i);” system.out.println(result);=”” }=””>
can someone help me out to get a java code for the following :-
the question is to encode a” loop to print the sum of the given series :-
1+1/4+1/7+1/10+1/13+1/16+1/19+1/22″
/**
* @(#)
*Problem: Write a program that accepts a positive number(n).
*loop from 1 to n,
*if a number is divisible by 3,print fizz
*if a number is divisible by 5, print buzz
*if a number is divisible by 3 and 5, print fizzbuzz
Enter no; 16
1
2
3 fizzz
4
5 buzz
6
7
8
9
10
11
12
13
14
15 Fizzbuzz
16
The program: You are to write a program called MinilabLoopLogic
which does the following:
Asks
the user to enter 2 integers (can be one prompt or two)
Gets
and stores the ints
Explains
that the program will generate all integers that are between the numbers
and are divisible by a third integer.
Asks
the user for the number they should be divisible by
Gets
and stores that int
Since
0 will be an illegal input to your program, keep asking them for the
number they should be divisible by while they keep doing it wrong.
If the
first number is smaller, then generate divisible numbers from the first up
to the second (not including the two numbers themselves)
Else
generate divisible numbers from the first down to the second (not
including the two numbers themselves)
I would appreciate some help. [email protected] that’s my email.
Thank you so much.
public class NameTriangle {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print(“Enter your first name: “);
String name = input.nextLine();
for(int i = 0; i < name.length(); i++){
System.out.println(name.substring(0, i + 1).toUpperCase());
}
}
}
******
*****
***
**
*
I want a program to print the following series
S=10-20+30-40+50……..n
Plz help