Explore BrainMass

Three sample java programs

Dear OTA,

Please help me in solving the follwing JAVA program.

Homework -- Week3Project2
? Write a program that uses loops to output some information.
? The program should have two classes.
? The class with the main method should be named CountXXXStart.
? The other class should be named CountXXX.
? The CountXXXStart file should provide a menu using a switch statement.
? The switch statement should include a while statement so the user can make more than one selection on the menu.
? The switch statement should also provide an option to exit the program when the user is ready
? The CountXXX class should use methods with self explanatory names to process and output the desired results.
? The first method should output the counting numbers six numbers per line from 76 to 28 in descending order.
? The second method should output all the counting numbers greater than 28 and less than 44 or greater than 56 and less than 88 in ascending order with 4 numbers printed to a line.
? The third method should have the user enter two counting numbers. Print to the DOS window all the counting numbers greater in value than the lowest number entered but less in value than the highest number entered. Have the program print three numbers per line on the output in ascending order.

Homework -- Week4Project1

? Your Week4Project1 coding project file should be named
? The program should allow the user to enter the weight in pounds of an indefinite number of people. Have the user enter the weights as integer values. Use a sentinal value of -1 when you are done entering the information.
? Calculate the average weight for all the people.
? Print the average weight of all the people to the DOS screen.
? Print to the DOS screen the number of people on which information was entered.
? Print the highest weight and the lowest weight of all the weights entered.

Homework -- Week4Project2

? Your Week4Project2 coding project should contain two classes.
? One class should be named DogProgramXXX and the other DogXXX.
? The DogProgramXXX class should contain the main method.
? The DogProgramXXX class should create six instant Dog objects using the DogXXX class.
? The program should assign identifiers to each of the Dog objects created.
? The DogXXX class should contain one method named dogData().
? The dogData() method should accept four arguments for each of the objects created.
? The arguments should be the name, species, sex, and currentAge.
? Display in the DOS window the four attributes of each Dog object created.
? Also calculate and display each Dog's age in dog years. (Assume 1 human year equals 7 dog years so a 3 year old dog would be 21 in dog years.)

Solution Preview

Here are the java files for each of the assignments from the problem statement. Remember that each public class needs to be in a file with the same name as the class.

---- ----
import java.util.Scanner;

public class CountXXXStart {

private static void PrintMenu() {
System.out.println("-- MENU -- ");
System.out.println("1) count down");
System.out.println("2) count up");
System.out.println("3) count between");
System.out.println("0) exit");
System.out.print("Enter choice: ");

public static void main(String[] args) {
Scanner in = new Scanner(;
CountXXX counter = new CountXXX();

int choice = 0;
do {
choice = in.nextInt();
switch (choice) {
case 1:
case 2:
case 3:
System.out.print("Enter the starting number: ");
int start = in.nextInt();
System.out.print("Enter the stopping number: ");
int stop = ...

Solution Summary

In this solution I show three simple java programs. The programs demonstrate the use of classes, methods, and while loops.