All Questions
109 questions
0
votes
3
answers
263
views
How to put asterisks on for looping
System.out.println("Enter your number");
int num = scanner.nextInt();
int count = 1;
for(int i = 1; i <= num; i++) {
for(int j = 1; j <= 1; j++) {
for(int k ...
0
votes
0
answers
27
views
Why do I have incompatible types error when Iterate Map in Java using keySet()? [duplicate]
sI have Class 1 where I have
protected Map<String, Object> parameter = new HashMap<String, Object>();
I have Class 2 that extends Class1 and where I do
List list = this.dao.createSQLQuery(...
0
votes
2
answers
99
views
How does this for loop output a decending number of "#" (top being most amount while bottom being least)?
I'm attempting to solve some Java questions and I came across a question that asked me to print out a diamond of size n.
Since I got stumped on this question, I decided to look up other's solutions to ...
0
votes
1
answer
529
views
Java: For Loop iterating strangely causing out of bounds errors
I have a for loop that iterates through a string of numbers. I also have an array that is the same length of the string consisting of numbers that represent that index's max value. The code iterates ...
0
votes
2
answers
381
views
For loop to iterate through user input to calculate cost?
I'm working in Java. So what I'm trying to do is, take the user input from subscriberPackage
public static String subscriberPackage() { //Method to get the customers name
Scanner sc = ...
0
votes
3
answers
133
views
Is there a way to allow for the number of for loops and array elements to be variable in algorithm? - java
Currently writing a program that finds the optimal ratio of 3 given numbers in an array. However the code I have currently only takes 3 numbers and arranges them to find the closest 3 number ...
0
votes
1
answer
58
views
How to map ArrayList elements with specific values and then print it
ArrayList<Integer> companiesId = new ArrayList<>();
int numberOfCompanies = 10; // Just for example
...
float profit;
Scanner input = new Scanner(System.in);
for(int i = 0; i < ...
0
votes
1
answer
314
views
How to loop through 2 different arrays in one loop in Java
I'm creating a method in my program that tells whether the if the user is at risk of covid through these question markers that has specific health risk categories (low, medium, high). The expected ...
0
votes
0
answers
100
views
JAVA : Not printing the last iteration of the loop until I press enter
I am currently trying to make a simple program that will calculate the number of vowels in multiple sentences. The input looks like this:
6
Emily jumped high
Alex did not jump
Phillip hates jumping
...
-2
votes
2
answers
867
views
For Loop for Decimal values
I'm getting two values like
a=2.7 (It can be anything in decimal for e.g 2.007 & ..)
b=3.5 (It can be anything in decimal for e.g 3.007 & ..)
I want to extract all value between 2.7 to 3.5 i.e....
0
votes
1
answer
315
views
how to store and print row number separated by comma in a for loop in a Java Program, I am using Java 4,looking for alternatives of List in Java 4
enter image description hereI have multiple rows on billing screen application built on Java 4 and it doesn't support List(If I use List, it shows error that "Save project compliance and JRE to 1....
-1
votes
3
answers
227
views
loop through two different Arrays java
sorry if this is an stupid question or anything; but I'm having a problem looping through two different objects in java. one of them is a hashmap and the other one is an arraylist. the objects look ...
-2
votes
1
answer
44
views
I'm trying to call a method through a for loop, and the first iteration will only read the first line of code in the method
I'm trying to use an enhanced for loop to call a method many times in a row, but if I'm iterating more than once, the first iteration will only read the first line of code. Here are both of the ...
0
votes
1
answer
267
views
Using a for-loop in java to capture player names is outputting wrong number and skipping first player
I'm creating a game in java. I have written separate a method for capturing the number of players who are playing (which is working), and with the below method I am trying to capture their names, ...
0
votes
1
answer
38
views
I would like to display numbers in a certain way but it's off-centre
I want to display number in rows, where the number of rows is asked as user input and the number of columns is always 4. It all works fine but it's off-centre. This is my code:
public class Practise {
...