Purchase Solution

Three sample java programs

Not what you're looking for?

Ask Custom Question

Please help me in solving the following 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 PeopleXXX.java
? 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 sentinel 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.)

Purchase this Solution

Solution Summary

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

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.

---- CountXXXStart.java ----
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(System.in);
CountXXX counter = new CountXXX();

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

Purchase this Solution


Free BrainMass Quizzes
Basic Networking Questions

This quiz consists of some basic networking questions.

Javscript Basics

Quiz on basics of javascript programming language.

C# variables and classes

This quiz contains questions about C# classes and variables.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.