This is a class assignment that has been puzzling me for a few hours. I need this to print out the values from the passenger array. My code so far prints the values from my aircraft class perfectly but not from my passenger class. Please see my output below:
How do I make the output display...
Hello I like Serena! When I run my program it fails. I keep encountering this message. The last program I made with exceptions didn't have any error messages. Thank you for answering me! :-)
Hello mathhelpboards community! I can't figure out how to get my code to execute while using buffered reader and try with resources. :-( I created a data.txt file correctly and it contains the numbers "0.5 3 10 70 90 80 20" without quotes. I added a catch IO Exception utilizing the...
Okay, I added elements to the second array. Is there something I'm missing? The program still won't display the original numbers. Thank you for the response!package calcavgdropsmallest;import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Scanner;
import...
Hello mathhelpboards community! Please help! Thank you. :-)
I need my code to print out the user's original array that is to say the numbers in the way the user entered them. I tried making a copy of the original array and then did all of the arithmetic on it. I sorted the array copy in...
Never mind, I figured it out. It doesn't stop between 5 and 10 inputs but as long as the user follows the prompt it should be okay. public static double [] getArrayNumbers(){
Scanner input = new Scanner(System.in);
String numbers = input.nextLine();
String[] strHolder =...
I want to alter my program so it can take an unknown amount of elements (user inputs). I want the program to automatically count the numbers the user is inputting up until they hit enter to the next line. I think I got the program to keep track of this but now my output is a bunch of zeros in...
Wow! Thank you for the detailed response. Your explanation helped immensely. Here is what I ended up with.
package patternmakerwithmethods;
import java.util.Scanner;
public class PatternMakerWithMethods {
public static int getNumberColumns(){
Scanner in = new...
I am having a difficult time with methods in java. I've been able to get my program to run correctly without methods. My for loop does as intended by printing an alternating rectangular pattern with no separator at the ends. However, after trying to decompose my code into 3 methods I've hit a...
I don't know why I thought the inner loop absolutely had to keep decreasing past 0. Also, I wasn't quite sure on placements for the braces but now I think I've got it. My teacher tends to not use them in her codes.
Thank you for taking the time to help me learn. :-)
I'm sorry about that I should've been much clearer! There is no specific problem just a lack of understanding about decrementing nested for loops.
The first code I had posted above used this particular line that I am having trouble wrapping my head around.
#include <iostream>
using namespace...
Hello! :-) I am having a hard time with understanding the logic behind decrementing nested for loops. The review problem I'm dealing with is below. This one makes the numbers go backwards.
#include <iostream>
using namespace std;
int main(){
for (int i = 0; i < 5; i++){
for (int j = i; j >=...
My code almost does what I want it to do. It displays the position of the duplicate but does the last duplicate position instead of the first. However, I didn't know there was a function called find_first_of! I was trying to use break to exit out of the loop after finding the first duplicate and...