Ok, I need help on a for loop nested program using for loops, I'm trying to use a patten that goes like this:
123456
12345
1234
123
12
1
but when I try it, it goes like this:
123456
12345
1234
123
12
1
This is my program:
public class Patterns{
public static void main (String [] args) {
//set up for the rows
for(int row = 7 ; row > 1; row--){
for (int num = 1; num < row; num++){
System.out.print(num);
}
System.out.println();
}
}
}
Can anybody help please? thanks
12 2213
Ok, I need help on a for loop nested program using for loops, I'm trying to use a patten that goes like this:
123456
12345
1234
123
12
1
but when I try it, it goes like this:
123456
12345
1234
123
12
1
This is my program: -
public class Patterns{
-
public static void main (String [] args) {
-
-
//set up for the rows
-
-
for(int row = 7 ; row > 1; row--){
-
-
for (int num = 1; num < row; num++){
-
-
System.out.print(num);
-
}
-
System.out.println();
-
}
-
-
}
-
-
}
-
Can anybody help please? thanks
Hi,
Please use code tags while posting code.
Your desired output and program output is same ... then what is the problem ?
I'm sorry, it must have typed it wrong, this is what I'm looking for: 123456 12345 1234 123 12 1
I'm sorry, it must have typed it wrong, this is what I'm looking for: 123456 12345 1234 123 12 1
Have you written down your algorithm for this first?
algorithm? I don't think we learned that yet?
algorithm? I don't think we learned that yet?
Main Entry: al·go·rithm
Pronunciation: 'al-g&-"ri-[th]&m
Function: noun
Etymology: alteration of Middle English algorisme, from Old French & Medieval
Latin; Old French, from Medieval Latin algorismus, from Arabic al-khuwArizmi,
from al-KhwArizmI fl A.D. 825 Islamic mathematician
: a procedure for solving a mathematical problem (as of finding the greatest
common divisor) in a finite number of steps that frequently involves repetition of
an operation; broadly : a step-by-step procedure for solving a problem or
accomplishing some end especially by a computer
kind regards,
Jos
algorithm? I don't think we learned that yet?
An algorithm is similar to a recipe - instructions on how to do a job in loads of little steps.
For example, the algorithm to boil water may be: - Make sure, you have a kitchen (if you don't, create one).
- Make sure, you have a pot (if you don't, create one).
- Make sure, you have a tap (if you don't, create one).
- Make sure, you have a oven (if you don't, create one).
- Go into the kitchen (may be complex, depending on your current position).
- Get a pot out of the shelves (may be more complex, e.g. if there are doors).
- Position the pot under the water tap (you may have to push it to one side before).
- Turn the tap on (there are loads of different taps).
- While the pot isn't full enough, keep checking, if the pot is full enough (you may want to take a break every time you've checked).
- When the pot is full, turn the tap off (same issue as turning it on).
- Lift the pot.
- Position the pot on the oven.
- Switch the oven on (depending on your type of oven, this could work in different ways).
- While the water isn't boiling, check if it's boiling.
I know, that is very detailed, but that's how you have to think when writing a program. A person would understand the command "boil water", but a computer needs all of these steps.
Greetings,
Nepomuk
I know, that is very detailed, but that's how you have to think when writing a program. A person would understand the command "boil water", but a computer needs all of these steps.
Greetings,
Nepomuk
Two questions for a mathematician and a physicist
Question 1:
There's a bunsen burner, a book of matches a water tap and an empty kettle;
how to boil water?
Both the physicist and the mathematician come up with an identical answer:
open the tap, filll the kettle, close the tap again, put the kettle on the bunsen
burner, light it using the matches and wait.
Question 2:
There's a filled kettle positioned on the bunsen burner; how to boil water?
The physicist's answer: light the burner and wait.
The mathematician's answer: empty the kettle; now the problem is reduced to
the previous question.
kind regards,
Jos ;-)
Two questions for a mathematician and a physicist
Question 1:
There's a bunsen burner, a book of matches a water tap and an empty kettle;
how to boil water?
Both the physicist and the mathematician come up with an identical answer:
open the tap, filll the kettle, close the tap again, put the kettle on the bunsen
burner, light it using the matches and wait.
Question 2:
There's a filled kettle positioned on the bunsen burner; how to boil water?
The physicist's answer: light the burner and wait.
The mathematician's answer: empty the kettle; now the problem is reduced to
the previous question.
kind regards,
Jos ;-)
Nice one! ^^
ERP! But once the kettle is empty, there's no specific mention of a tap? Where will the mathematician get the water? And besides, there aren't any matches.
ERP! But once the kettle is empty, there's no specific mention of a tap? Where will the mathematician get the water? And besides, there aren't any matches.
Yep, you're right (bloody nitpickers ...) I should've defined both problems in a bit
more detail; but I hope you get the idea ;-)
kind regards,
Jos
(bloody nitpickers ...)
Wait, almost 50% of every post I've seen you make is nitpicking - you even admit so yourself on many occasions.
Wait, almost 50% of every post I've seen you make is nitpicking - you even admit so yourself on many occasions.
That wasn't me.
kind regards,
Loretta ;-)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Drew |
last post by:
We have a string like: 2004\05\05T00:00:00
We would like to remove all "\", any "-" and the T00:00:00 part of the
string.
The end result would...
|
by: kittykat |
last post by:
Hi,
I was wondering if you could help me. I am writing a program in C++, and
the problem is, i have very limited experience in this language.
I...
|
by: pitachu |
last post by:
Hi,
I'm not an expect in .NET, so would anyone know an answer a design
pattern for the following?
There are many customers that require minor...
|
by: Steven Nagy |
last post by:
So I was needing some extra power from my enums and implemented the
typesafe enum pattern.
And it got me to thinking... why should I EVER use...
|
by: td0g03 |
last post by:
Hello, I just have a few questions. The first one be how would you print a pattern. I could use the if else, but I remember my teacher talking about...
|
by: halekio |
last post by:
Hi all,
Please bear with me as I've only started programming in C# 2 weeks ago
and this is my first contact with OOP.
I ran into a situation...
|
by: halekio |
last post by:
Hi all,
Please bear with me as I've only started programming in C# 2 weeks ago
and this is my first contact with OOP.
I ran into a situation...
|
by: konrad Krupa |
last post by:
I'm not expert in Pattern Matching and it would take me a while to come up
with the syntax for what I'm trying to do.
I hope there are some experts...
|
by: arunbs84 |
last post by:
hi friends this is arun from coimbatore.i had written one program for pattern matching.That is ,the user have one file and after run his c program he...
|
by: NoviceJava |
last post by:
Hey,
I'm having trouble with an assignment and I need some help.
basically, the assignment is the same as the from the following link:...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
| |