I need help with the following. I need to write a program code in Java using NetBeans. It is from How to Program Java book Chapter 2.
This program should calculate the packing of Candles. First read:
The number of candles
The number of candles that fit in each case
Then calculate and print:
The number of full cases
The number of candles left over (partial case)
If this order is large (more than 5 full cases needed)
An extra message at the end to say you are done
Requirements:
Put System.out.println() after each call to nextInt().This will help you match the Test Program and make it easier to use it.
Even though you can do this with less variables, make sure you declare and use a variable for the number of full cases and another for the number left over
Sample Run #1: (the highlighted text is what the user types)
Num candles? 20
Candles per case? 8
2 cases 4 leftover
Done!
Sample Run #2: (the highlighted text is what the user types)
Num candles? 40
Candles per case? 6
6 cases 4 leftover
*** large order
Done!
Extra Notes:
Did you correctly name the package/folder?
Did you correctly name the class/file?
Did you include comments?
hi..
//Java 8
/*
Initial Thoughts:
We can keep a running max and update it if we
find something larger, if we find something smaller
we just keep looking and if we find something equal
then we increment a counter variable
Time Complexity: O(n) //We must check the height of every candle
Space Complexity: O(1) //We only store a max and a frequency
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int tallest = 0;
int frequency = 0;
for(int i=0; i < n; i++){
int height = in.nextInt();
if(height > tallest){
tallest = height;
frequency = 1;
}
else if(height == tallest) frequency++;
}
System.out.println(frequency);
}
I need help with the following. I need to write a program code in Java using...
Following is my java program that i need help with. Write a program that uses a JavaFX GUI that allows a user to enter a directory (folder) and then displays the number of the files in the directory. The number of files in the directory should be determined recursively.
I need help with this code: Write a program that calculates the future value of an investment at a given interest rate for a specified number of years. The formula for the calculation is as follows: futureValue = investmentAmount * (1 + monthlyInterestRate)years*12 Use text fields for interest rate, investment amount, and years. Display the future amount in a text field when the user clicks the Calculate button, as shown in the following figure. It needs to be done in...
(Java) HELP! Create a program that will ask the user to enter their first name and their favorite number. Ask the user if they would like the information repeated back to them. If they type "Y" display the answers back to them. If they type anything else, display the word "Goodbye". An example of what your output window should look like is below. The system-generated output is in red. The user-provided input is in green. (Your actual program will only...
Write a java netbeans program. Project Two, Super Bowl A text file named “SuperBowlWinners.txt” contains the names of the teams that won the Super Bowl from 1967 through 2019. Write a program that repeatedly allows a user to enter a team name and then displays the number of times and the years in which that team won the Super Bowl. If the team entered by the user has never won the Super Bowl, report that to the user instead. For...
.Need code for my java class !! Write a simple java program that uses loops. You may use ‘WHILE’ or ‘FOR’ or ‘DO-WHILE’ – you decide. The program should use a loop to compute the semester average for up to 5 students. In the loop the user will ask for a student name and their 3 test scores and add them up and divide the total by 3 giving the semester average. You will print out the student name and...
Need help answering the following using java 2a. Write a java program (just a “void main”) that will reverse the digits of a user entered, positive three-digit number. You can assume the user enters an integer. Your code segment should first verify that the user has entered a number from 100 to 999 (error message if not). If the user has entered a three-digit number, output a new number with the original digits reversed. 2b. Instead of being limited to...
JAVA PROGRAM Write a program that contains the following two methods Write a method that accepts a user string as a parameter and converts any words that are in all uppercase to all lowercase. Note: the first letter at the start of a sentence should remain in upper case if that is what the user enters. See example below. Enter Initial Text: (prompts user for text) Currently: HEY! What do you think about this CRAZY STUFF!! WHAT a day. Revised...
Please help me write this Java program. I had posted this question before, but got an answer that was totally wrong. We are using the latest version of Java8. Thank You! -------------------------------------------------------------------------------------- Write a Java program that can successfully DECRYPT a string inputted by the user which has been encrypted using a Caesar Cipher with a unknown shift value(key). You can use brute force to do a for loop through all the 26 shift values, however, your program should only...
Java code Guessing Game Refinement. (The user thinks of a
number and the program guesses it) Program should be able to guess
correctly in 7 tries or lower.
Initialize a variable that represents the lowest possible
number to 0 (what type should this be?)
Initialize a variable that represent the highest possible
number to 100 (what type should this be?)
Initialize a Boolean variable that represents if we’ve
achieved the correct guess to false
Initialize a variable in which to...
Java How to Program, Early Objects ISBN-13: 9780133813432 Project Name: C2800_Proj1_RaceGame Source File Name: (Submit zip of these) RaceGame.java (contains main) RaceCar.java RaceGame is a text based car racing game. The user is car #1 and the computer is car #2. A car is drawn using 2 lines. The number on the first line is 1 for the user and 2 for the computer. __/1\__ -O---O- When the car has moved down the track, print underscore’s on the second line...