My professor asked me to make a program about cashier using Java. The program is supposed to be inputting the codename of the product and how much you buy it. Before printing the value, the program will ask you “do you want to count another [Y/N]”. If the user inputting Y then the user will asked to input another value.
Tag: loops
What is the quickest way to determine if two elements are in the same row or column in a 2D array?
As part of one of my programs, I’m trying to check if two elements in a 2D array are part of the same row or column. I know there might be many ways to go about this, mainly with loops and by iterating through the array, but I was just wondering: is there any quick way to determine this? Let’s
Invert incrementing triangle pattern
I am writing some code that creates a incrementing number right angle triangle that looks something like this: I am unsure on how to make my code output a triangle to that shape as my code outputs the same thing except inverted. This is the code I have: My speculation is that instead of incrementing some of the values I
How do I work with objects in lists and can I create multiple objects with different names in a loop?
I need to create Objects of a class called “Tile”. I have 9×9 chess board like grid and want to initiate the whole board at once. The position of a Tile is defined by an x and y-axis and I need to work with those later. I thought about doing it with a loop but I want each object to
Zipped String from 2 (or more) Strings – “AB” + “YZ” = “AYBZ”
So I am trying to return another String from 2 input sentences zipped together. If the 2 sentences are identical in length it will produce an actual output. If the two input sentences are not identical in length then it will just return an empty string. Here is my code so far but I can’t figure out how to zip
Representation of an array as a polynomial
What this method should do is take an array of doubles and convert them into a polynomial, for example, if the array is given was [2.0, 3.0, -2.0] the method’s output would be 2.0x^2 + 3.0x^1 – 2.0. …
How to check password for number of lowercase letters entered?
I am using the below script to check my passwords for length, number of uppercase letters and number of digits. Is there a way to make it also check for the number of lowercase letters? I tried to revamp my code a few times but each time I do it kicks out the other two checks. Thanks in advance! Answer
How do I get the numberOfQuestions variable to reset back to Zero after the loop completes?
/*Class MentalMathProgram Michael 11/18/2020 This program is designed to present the user with randomly generated numbers and it gets progressively harder for every question correct. / import java.util.; public class mentalMathProgram { This is my code but I’m very new to coding. Im just trying to reset the variable that controls the amount of questions presented to the user to
Java method for checking for duplicate values in an array outputs new line for each duplicate value [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question I’ve created a method in java that checks (and counts) for duplicate values in an array: Given the array {string1,
How to create a ‘best fit’ comparison of several integers and an input integer in Java?
I have 3 (subject to change to more rooms in the future, but that’s irrelevant) rooms, all with a different number of seats (suppose these are ‘Room’ Objects): Room Seats 1 10 2 20 3 30 I then input a value of the number of seats I need to reserve and then my code will automatically assign the user a