Modify the CountByFives application so that the user enters the value to count by. Start each new line after 10 values have been displayed.
public class CountByAnything
{
// Modify the code below
public static void main (String args[])
{
final int START = 5;
final int STOP = 500;
final int NUMBER_PER_LINE = 50;
for(int i = START; i <= STOP; i += START)
{
System.out.print(i + " ");
if(i % NUMBER_PER_LINE == 0)
System.out.println();
}
}
}
import java.util.Scanner;
public class CountByAnything
{
// Modify the code below
public static void main (String args[])
{
final int START = 5;
final int STOP = 500;
final int NUMBER_PER_LINE = 10;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter count value: ");
int step = scanner.nextInt();
int temp = 1;
for(int i = START; i <= STOP; i += step)
{
System.out.print(i + " ");
temp++;
if(temp % NUMBER_PER_LINE == 0)
System.out.println();
}
}
}



Modify the CountByFives application so that the user enters the value to count by. Start each...
I do not know how to code this. I have tried several
times.
Instructions CountByAnything.java + Modify the CountByFives application so that the user enters the value to count by. Start each new line after 10 values have been displayed. 1 public class CountByAnything 2 { // Modify the code below 4 public static void main(String args[]) { Grading final int START; final int STOP = 500; final int NUMBER_PER_LINE = 10; for(int i = START; i <= STOP; i...
I need help asking the user to half the value of the displayed random number as well as storing each number generated by the program into another array list and displayed after the game is over at the end java.util.*; public class TestCode { public static void main(String[] args) { String choice = "Yes"; Random random = new Random(); Scanner scanner = new Scanner(System.in); ArrayList<Integer> data = new ArrayList<Integer>(); int count = 0; while (!choice.equals("No")) { int randomInt =...
Modify the program so that it uses a loops repeatedly doing: • prompt for input (using line seqNum and the prompt phrase: "Enter a line") • reads the line of input • stores the line of input in the next position of an array of Line or an ArrayList of Line. Once the user enters STOP as input, the loop should terminate and another loop should print each line in reverse order. For example (the input you should type in...
I need to write a program in java that reads a text file with a list of numbers and sorts them from least to greatest. This is the starter file. import java.util.*; import java.io.*; public class Lab3 { static final int INITIAL_CAPACITY = 5; public static void main( String args[] ) throws Exception { // ALWAYS TEST FOR REQUIRED INPUT FILE NAME ON THE COMMAND LINE if (args.length < 1 ) { System.out.println("\nusage: C:\\> java Lab3 L3input.txt\n"); System.exit(0); } //...
using Data Structures using Java. Modify it to make the ADT resizable. For this ADT, the MAX_SIZE will not be final, but rather will be increased whenever an new item needs to be added and the array is full (ie. size==MAX_SIZE). Whenever the array needs to grow, add the lesser of: (i) half the current size, or; (ii) 50 additional. Have your ADT report its old and new maximum size whenever the resize operation is called by printing “ADT resized...
/**
*
* Jumping frog game: user enters road length and series of jumps and
* the program displays the current position of the frog.
*/
public class hw4_task5 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int playAgain = 1;
int roadLen;
System.out.println("JUMPING FROG");
while (playAgain == 1){
System.out.printf("Enter the length of the road: ");
roadLen = in.nextInt();
play(roadLen); // Starts a new game with a road this long.
System.out.printf("\nDo you want to play again...
Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds,...
Modify the virtual translator program: virtual.java Modify it so it loops ten times asking the user for the ten virtual address from the work sheet we did the week before spring break. Once you have it working run it in a script command capturing the output. Make sure the script file has a .txt extension and upload the output. //Java Program import java.util.Scanner; public class virtual{ public static void main(String[] args){ int[] virtualAddressPace={2,1,6,0,4,3,-1,-1,-1,5,-1,7,-1,-1,-1,-1}; Scanner input = new...
Java 1. Create an application named NumbersDemo whose main() method holds two integer variables. Assign values to the variables. In turn, pass each value to methods named displayTwiceTheNumber(), displayNumberPlusFive(), and displayNumberSquared(). Create each method to perform the task its name implies. 2. Modify the NumbersDemo class to accept the values of the two integers from a user at the keyboard. This is the base code given: public class NumbersDemo { public static void main (String args[]) { // Write your...
you created an application named QuartsToGallonsInteractive that accepts a number of quarts from a user and converts the value to gallons. Now, add exception-handling capabilities to this program and continuously reprompt the user while any nonnumeric value is entered. // QuartsToGallonsInteractive.java import java.util.Scanner; class QuartsToGallonsInteractive { public static void main(String[] args) { final int QUARTS_IN_GALLON = 4; int quartsNeeded = 18; int gallonsNeeded; int extraQuartsNeeded; Scanner input = new Scanner(System.in); System.out.print("Enter quarts...