hello everyone,i'm really new at java...but they said that an I.T student like me should learn and apply Java very well.I always try my best( as every1 do) to learn and apply Java codes or whatever...but this time,i'm very confused.this is related to incrementing and decrementing values.

our Instructor ordered us to make 2 separate programs.

first 1 has this process:(INPUT VALUE MAY VARY DEPENDING ON THE USER)

ex:
INPUT NUMBER:5
OUTPUT:
*
* *
* * *
* * * *
* * * * *

(actually, the asterisks should form like a pyramid NOT a right triangle)

2nd prog:(about !(factorial)(INPUT VALUE MAY VARY DEPENDING ON THE USER)
INPUT:5
OUTPUT:125


i wonder what is the right code for these 2 machine problem..
i'm very sorry because i'm new at these...hope 4 ur help..tnx :D

First write a program to read an integer from the user.
Then add a loop to print out '*'s from 1 a line to the number per line.
See println() and print() for doing the output.

Type in your code, compile it and execute it. Come back if you need more help.

Try this one & Come back if you need more help

import java.util.Scanner;

class Gayan{
	public static void main(String args[]){

//get number from user

	Scanner AB=new Scanner(System.in);
	System.out.println("Enter the number:-");
	int x=AB.nextInt();

//print asterisks pyramid

		for(int a=0;a<x;a++){
			for(int b=4;b>a;b--){
				System.out.print(" ");
			}
			for(int c=0;c<=a;c++){
				System.out.print("*");
			}
			for(int d=0;d<a;d++){
				System.out.print("*");
			}
			System.out.println();
		}
	}
}
import java.util.Scanner; class Gayan{	public static void main(String args[]){ //get number from user 	Scanner AB=new Scanner(System.in);	System.out.println("Enter the number:-");	int x=AB.nextInt(); //print asterisks pyramid 		for(int a=0;a<x;a++){			for(int b=4;b>a;b--){				System.out.print(" ");			}			for(int c=0;c<=a;c++){				System.out.print("*");			}			for(int d=0;d<a;d++){				System.out.print("*");			}			System.out.println();		}	}}import java.util.Scanner;

class Gayan{
	public static void main(String args[]){

//get number from user

	Scanner AB=new Scanner(System.in);
	System.out.println("Enter the number:-");
	int x=AB.nextInt();

//print asterisks pyramid

		for(int a=0;a<x;a++){
			for(int b=4;b>a;b--){
				System.out.print(" ");
			}
			for(int c=0;c<=a;c++){
				System.out.print("*");
			}
			for(int d=0;d<a;d++){
				System.out.print("*");
			}
			System.out.println();
		}
	}
}

thank you very much for your help.

though i received a warning from admins about the way of my english..:))

i' glad you helped,

I don't know if it's just okay but when the value(number)is large..it doesn't show pyramid anymore.

i'm really sorry because i'm not at this. :D

check this attachment.

THANK YOU VERY MUCH:)

for(int b=4;b>a;b--){

Look at this code. It has a HARDCODED 4 in it. With no explanation on why it's using 4 vs computing a value. In fact there are NO comments at all in the code explaining how it works.
If the author of the code wants to help you learn programming, he should explain how he solved the problem and how the code works.
Just posting code is lazy.

for(int b=4;b>a;b--){

Look at this code. It has a HARDCODED 4 in it. With no explanation on why it's using 4 vs computing a value. In fact there are NO comments at all in the code explaining how it works.
If the author of the code wants to help you learn programming, he should explain how he solved the problem and how the code works.
Just posting code is lazy.

i appreciate your opinion...but we'll be more glad if you'll explain rather than nagging.:D
it will all give us benefits:D

told you...i'm new at this.^^

i appreciate your opinion...but we'll be more glad if you'll explain rather than nagging.:D
it will all give us benefits:D

told you...i'm new at this.^^

That is poor excuse... Be glad that somebody posted code for you, even though it does not work properly. You should build on it and improve it.

That is poor excuse... Be glad that somebody posted code for you, even though it does not work properly. You should build on it and improve it.

i don't remember i asked for a code,i already improved it and now it's working.if you guys came over here just to mock or to mess...i guess you entered a wrong thread.

i'm really glad someone helped me.

**
you are talking to a newbie..thank you.

i don't remember i asked for a code

First thread...

i wonder what is the right code for these 2 machine problem..
i'm very sorry because i'm new at these...hope 4 ur help..tnx :D

I do not have time for mockery, I'm interested in helping others as long they willing to learn.

Hahaaa

Don't give this 'homework kiddo' any help

First thread...


I do not have time for mockery, I'm interested in helping others as long they willing to learn.

whoa...do you think i'm not willing to learn??....are you helping??!...anyway.thanks again.

Hahaaa

Don't give this 'homework kiddo' any help

haha,..funnyXD

@iskalabatoto I'm closing thread as you show bad attitude and instead of discussing coding issue you rather moan about people for not helping you and attempting to flame. Take it as a warning for the future.

One more thing, when you create new thread provide full description of problem. Neither of your new threads show any quality in them

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.