Questions
For this assignment, you will modify existing code to create a single Java™ program named BicycleDemo.java...

For this assignment, you will modify existing code to create a single Java™ program named BicycleDemo.java that incorporates the following:

  • An abstract Bicycle class that contains private data relevant to all types of bicycles (cadence, speed, and gear) in addition to one new static variable: bicycleCount. The private data must be made visible via public getter and setter methods; the static variable must be set/manipulated in the Bicycle constructor and made visible via a public getter method.
  • Two concrete classes named MountainBike and RoadBike, both of which derive from the abstract Bicycle class and both of which add their own class-specific data and getter/setter methods.

Read through the "Lesson: Object-Oriented Programming Concepts" on The Java™ Tutorials website.

Download the linked Bicycle class, or cut-and-paste it at the top of a new Java™ project named BicycleDemo.

Download the linked BicycleDemo class, or cut-and-paste it beneath the Bicycle class in the BicycleDemo.java file.

Optionally, review this week's Individual "Week One Analyze Assignment," to refresh your understanding of how to code derived classes.

Adapt the Bicycle class by cutting and pasting the class into the NetBeans editor and completing the following:

  • Change the Bicycle class to be an abstract class.
  • Add a private variable of type integer named bicycleCount, and initialize this variable to 0.
  • Change the Bicycle constructor to add 1 to the bicycleCount each time a new object of type Bicycle is created.
  • Add a public getter method to return the current value of bicycleCount.
  • Derive two classes from Bicycle: MountainBike and RoadBike. To the MountainBike class, add the private variables tireTread (String) and mountainRating (int). To the RoadBike class, add the private variable maximumMPH (int).

Using the NetBeans editor, adapt the BicycleDemo class as follows:

  • Create two instances each of MountainBike and RoadBike.
  • Display the value of bicycleCount on the console.

Comment each line of code you add to explain what you added and why. Be sure to include a header comment that includes the name of the program, your name, PRG/421, and the date.

Rename your JAVA file to have a .txt file extension.

Submit your TXT file.

*******************CODE**************************

class Bicycle {

    int cadence = 0;
    int speed = 0;
    int gear = 1;

    void changeCadence(int newValue) {
         cadence = newValue;
    }

    void changeGear(int newValue) {
         gear = newValue;
    }

    void speedUp(int increment) {
         speed = speed + increment;   
    }

    void applyBrakes(int decrement) {
         speed = speed - decrement;
    }

    void printStates() {
         System.out.println("cadence:" +
             cadence + " speed:" + 
             speed + " gear:" + gear);
    }
}

***********************************SECOND CLASS********************************************

class BicycleDemo {
    public static void main(String[] args) {

        // Create two different 
        // Bicycle objects
        Bicycle bike1 = new Bicycle();
        Bicycle bike2 = new Bicycle();

        // Invoke methods on 
        // those objects
        bike1.changeCadence(50);
        bike1.speedUp(10);
        bike1.changeGear(2);
        bike1.printStates();

        bike2.changeCadence(50);
        bike2.speedUp(10);
        bike2.changeGear(2);
        bike2.changeCadence(40);
        bike2.speedUp(10);
        bike2.changeGear(3);
        bike2.printStates();
    }
}

In: Computer Science

The purpose of creating an abstract class is to model an abstract situation. Example: You work...

The purpose of creating an abstract class is to model an abstract situation.

Example:

You work for a company that has different types of customers: domestic, international, business partners, individuals, and so on. It well may be useful for you to "abstract out" all the information that is common to all of your customers, such as name, customer number, order history, etc., but also keep track of the information that is specific to different classes of customer. For example, you may want to keep track of additional information for international customers so that you can handle exchange rates and customs-related activities, or you may want to keep track of additional tax-, company-, and department-related information for business customers.

Modeling all these customers as one abstract class ("Customer") from which many specialized customer classes derive or inherit ("InternationalCustomer," "BusinessCustomer," etc.) will allow you to define all of that information your customers have in common and put it in the "Customer" class, and when you derive your specialized customer classes from the abstract Customer class you will be able to reuse all of those abstract data/methods.This approach reduces the coding you have to do which, in turn, reduces the probability of errors you will make. It also allows you, as a programmer, to reduce the cost of producing and maintaining the program.

In this assignment, you will analyze Java™ code that declares one abstract class and derives three concrete classes from that one abstract class. You will read through the code and predict the output of the program.

Read through the linked Java™ code carefully.

Predict the result of running the Java™ code. Write your prediction into a Microsoft® Word document, focusing specifically on what text you think will appear on the console after running the Java™ code.

In the same Word document, answer the following question:

  • Why would a programmer choose to define a method in an abstract class, such as the Animal constructor method or the getName() method in the linked code example, as opposed to defining a method as abstract, such as the makeSound() method in the linked example?

CODE:

/**********************************************************************

*           Program:          PRG/421 Week 1 Analyze Assignment

*           Purpose:           Analyze the coding for an abstract class

*                                   and two derived classes, including overriding methods

*           Programmer:     Iam A. Student

*           Class:               PRG/421r13, Java Programming II

*           Instructor:        

*           Creation Date:   December 13, 2017

*

* Comments:

* Notice that in the abstract Animal class shown here, one method is

* concrete (the one that returns an animal's name) because all animals can

* be presumed to have a name. But one method, makeSound(), is declared as

* abstract, because each concrete animal must define/override the makeSound() method

* for itself--there is no generic sound that all animals make.

**********************************************************************/

package mytest;

// Animal is an abstract class because "animal" is conceptual

// for our purposes. We can't declare an instance of the Animal class,

// but we will be able to declare an instance of any concrete class

// that derives from the Animal class.

abstract class Animal {

// All animals have a name, so store that info here in the superclass.

// And make it private so that other programmers have to use the

// getter method to access the name of an animal.

private final String animalName;

// One-argument constructor requires a name.

public Animal(String aName) {

animalName = aName;

}

// Return the name of the animal when requested to do so via this

// getter method, getName().

public String getName() {

return animalName;

}

// Declare the makeSound() method abstract, as we have no way of knowing

// what sound a generic animal would make (in other words, this

// method MUST be defined differently for each type of animal,

// so we will not define it here--we will just declare a placeholder

// method in the animal superclass so that every class that derives from

// this superclass will need to provide an override method

// for makeSound()).

public abstract String makeSound();

};

// Create a concrete subclass named "Dog" that inherits from Animal.

// Because Dog is a concrete class, we can instantiate it.

class Dog extends Animal {

// This constructor passes the name of the dog to

// the Animal superclass to deal with.

public Dog(String nameOfDog) {

super(nameOfDog);

}

// This method is Dog-specific.

@Override

public String makeSound() {

return ("Woof");

}

}

// Create a concrete subclass named "Cat" that inherits from Animal.

// Because Cat is a concrete class, we can instantiate it.

class Cat extends Animal {

// This constructor passes the name of the cat on to the Animal

// superclass to deal with.

public Cat(String nameOfCat) {

super(nameOfCat);

}

// This method is Cat-specific.

@Override

public String makeSound() {

return ("Meow");

}

}

class Bird extends Animal {

// This constructor passes the name of the bird on to the Animal

// superclass to deal with.

public Bird (String nameOfBird) {

super(nameOfBird);

}

// This method is Bird-specific.

@Override

public String makeSound() {

return ("Squawk");

}

}

public class MyTest {

public static void main(String[] args) {

// Create an instance of the Dog class, passing it the name "Spot."

// The variable aDog that we create is of type Animal.

Animal aDog = new Dog("Spot");

// Create an instance of the Cat class, passing it the name "Fluffy."

// The variable aCat that we create is of type Animal.

Animal aCat = new Cat("Fluffy");

// Create an instance of (instantiate) the Bird class.

Animal aBird = new Bird("Tweety");

//Exercise two different methods of the aDog instance:

// 1) getName() (which was defined in the abstract Animal class)

// 2) makeSound() (which was defined in the concrete Dog class)

System.out.println("The dog named " + aDog.getName() + " will make this sound: " + aDog.makeSound());

//Exercise two different methods of the aCat instance:

// 1) getName() (which was defined in the abstract Animal class)

// 2) makeSound() (which was defined in the concrete Cat class)

System.out.println("The cat named " + aCat.getName() + " will make this sound: " + aCat.makeSound());

System.out.println("The bird named " + aBird.getName() + " will make this sound: " + aBird.makeSound());

}

}

In: Computer Science

How to print output vertically in the code attached below: import operator with open ('The Boy...

How to print output vertically in the code attached below:

import operator

with open ('The Boy .txt',encoding='utf8') as my_file:
 contents=my_file.read()

l = contents.strip()
words = l.split()


newdict = dict()

for i in words:
  if i in newdict:
   newdict[i] = newdict[i] + 1
  else:
   newdict[i] = 1

newly = dict()
sorted_Dict = sorted(newdict.items(), key=operator.itemgetter(1), reverse=True)
for n in sorted_Dict:
    newly[n[0]] = n[1]
print(newly)

with open('freqs.txt','w', encoding='utf8') as final:
    final.write(str(newly))







In: Computer Science

using c language: Add two vectors of doubles. Name this function vect_add(). Subtract two vectors of...

using c language:

Add two vectors of doubles. Name this function vect_add(). Subtract two vectors of doubles. Name this function vect_sub(). Multiplies element by element two vectors. Name this function vect_prod(). Compute and return the dot product of two vectors. Name this function vect_dot_prod(). The dot product operation is the result of taking two vectors(single dimension arrays) and multiplying corresponding element by element and then adding up the sum of all the products. For example, if I have 2 vectors of length 3 that have the following values {l, 2, 3} and {3, 2, l} the dot product of these two vectors is: 1*3+2*2+3*1 = 10 Compute and return the mean of a single vector. Name this function vect_mean(). Compute and return the median of a single vector. Name this function vect_median(). First sort the array. If the length of the sorted array is odd, then the median is the middle element. If the length is odd, the median is the average of the middle two elements. Compute and return the maximum element of a vector. Name this function vect_max(). Compute and return the minimum element of a vector. Name this function vect_min(). Write a function that reverses the elements in a given array. This function will change the original array, passed by reference. Name this function vect_reverse().

In: Computer Science

For this class exercise, each group will be assigned the file with the exercise number that...

For this class exercise, each group will be assigned the file with the exercise number that corresponds to their group. The group will analyze the code to determine what the code does, how the data is structured, and why it is the appropriate data structure. Note that these are various examples, some are partial code with just classes and methods and do not include the "main" or "test" code needed to execute. Each team will add a header describing the purpose of the program (each class and method), comments to the code, and walkthrough the code with the class, answering questions as the instructor. IF the code is executable, then your group will demonstrate the code. Submit your file with the commented code. Make sure to include the names of everyone in your group on the file.

.......................................................................................................................................................................................................................................................................................

import java.util.Iterator;

import java.util.LinkedList;

import java.util.Random;

public class ListTest3 {

    public static void main(String[] args) {

        LinkedList<Integer> list = new LinkedList<Integer>();

        int newNumber;

        Random randomNumber = new Random();

       

        for (int k = 0; k <25; k++) {

            newNumber = randomNumber.nextInt(101);

            list.add(newNumber);

        }

       

        Collections.sort(list);

        System.out.println(list);

       

        int count = 0;

        Iterator<Integer> iterator = list.iterator();

        while (iterator.hasNext()) {

            count += iterator.next();

        }

       

        System.out.printf("Sum is: %d%nAverage is: %.2f", count,

                          ((double) count / list.size()));

    }

}

In: Computer Science

Create a basic program (C Programming) that accomplishes the following requirements: Prints "for loop" and then...

Create a basic program (C Programming) that accomplishes the following requirements:

Prints "for loop" and then uses a for statement to count from 1 to 100.
Prints "while loop" and then uses a while statement to count from 1 to 100.
Prints "do while loop" and then use a do while statement to count from 1 to 100.
Using a nested if/else statement or a switch in one of the loops , print to the screen if a number is:
Less than or equal to 10 (print less than 11 to the screen)
Greater than or equal to 11 but less than 20. (print between 10 and 20 to the screen)
Greater than 21 (print greater than 21 to the screen)

In: Computer Science

Q2: Explain the generic model of the process of making and using digital signature?

Q2: Explain the generic model of the process of making and using digital signature?

In: Computer Science

In Python please. Construct a large file of data in random order where the key is...

In Python please.

Construct a large file of data in random order where the key is a 13-digit number.
Then sort in two different ways. Use a Quick sort and then use a radix sort of some kind. Code both sorts in the same language and run experiments to see at what size of data does the radix run faster than the Quick sort.

In: Computer Science

Answer in Python: show all code 3) Modify your code to take as input from the...

Answer in Python: show all code

3) Modify your code to take as input from the user the starting balance, the starting and ending interest rates, and the number of years the money is in the account. In addition, change your code (from problem 2) so that the program only prints out the balance at the end of the last year the money is in the account. (That is, don’t print out the balance during the intervening years.)

Sample Interaction:

Enter starting balance: 1000

Enter starting interest rate: 3

Enter ending interest rate: 5

Enter number of years: 5

Interest rate of 3 %:

Balance after year 5 is $ 1159.27

Interest rate of 4 %:

Balance after year 5 is $ 1216.65

Interest rate of 5 %:

Balance after year 5 is $ 1276.28

problem 2 instruction: to reference for this question:

2) For the last assignment you had to write a program that calculated and displayed the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years.

The program output looked like this:

Balance after year 1 is $ 1060.0

Balance after year 2 is $ 1123.6

Balance after year 3 is $ 1191.02

Balance after year 4 is $ 1262.48

Balance after year 5 is $ 1338.23

Modify your code so that it displays the balances for interest rates from three to five percent inclusive, in one percent intervals. (Hint: Use an outer loop that iterates on the interest rate, and an inner one that iterates on the year.)

Output:

Interest rate of 3 %:

Balance after year 1 is $ 1030.0

Balance after year 2 is $ 1060.9

Balance after year 3 is $ 1092.73

Balance after year 4 is $ 1125.51

Balance after year 5 is $ 1159.27

In: Computer Science

Write a C program that uses a loop which prompts a user for an integer 10...

Write a C program that uses a loop which prompts a user for an integer 10 times and stores those integers in an array. The program will print out the numbers entered by the user with a comma and a space separating each number so the numbers can be read easily. The program will then calculate and print out the sum, integer average and floating point average (to 4 decimal points) of the numbers in the array. The information being printed out should be labeled correctly with newline characters placed so the output is readable. You will also create a BubbleSort function to sort the integers from small to large. The array will be passed by reference to the function where the function will reorder the integers in the array. You should not duplicate the array in anyway.

Remember your assignment must be submitted by 11:59:59pm on the due date, or else it will be considered late and will not be accepted. Please make sure your C code is thoroughly commented to explain what your program is doing. You should only submit the C source code, not the compiled program.

NOTE: Pseudo-code for a basic Bubble Sort routine:

procedure BubbleSort( A : array of integers to sort)
  repeat
    swapped = false
      for item in A inclusive do:
        if A[i-1] > A[i] then
          swap A[i-1] and A[i]
          swapped = true
        end if
      end for
  until not swapped
end procedure

Sample Output:

$>./assignment3
Enter element  1 into the array 5
Enter element  2 into the array 7
Enter element  3 into the array 6
Enter element  4 into the array 1
Enter element  5 into the array 2
Enter element  6 into the array 3
Enter element  7 into the array 4
Enter element  8 into the array 8
Enter element  9 into the array 9
Enter element 10 into the array 0

5, 7, 6, 1, 2, 3, 4, 8, 9, 0

The sum of the integers in the array is 45
The integer average of the integers in the array is 4
The float average of the integers in the array is 4.5000

0, 1, 2, 3, 4, 5, 6, 7, 8, 9
$>

In: Computer Science

c++ Design the Weather class that contains the following members: Data members to store: -a day...

c++

Design the Weather class that contains the following members:

Data members to store:

-a day (an integer)

-a month (an integer)

-a year (an integer)

-a temperature (a float)

-a static data member that stores the total of all temperatures (a float)

Member functions:

-a constructor function that obtains a day, month, year and temperature from the user. This function should also accumulate/calculate the total of all temperatures (i.e., add the newly entered temperature to the total).

-a static function that computes and displays the day which has the lowest temperature. Note: An array of Weather objects and the size of the array will be passed to this function.

-a static function that computes and displays the average temperature. This function should use a parameter,if necessary.

Design the main( )function, which instantiates/creates any number of objects of the Weather class as requested by the user (i.e., creates a dynamic array of Weather objects). main( )should also call appropriate functions to compute and display the day that has the lowest temperature, as well as the average temperature.Your program should include all necessary error checking.

A sample run of this program could be as follows:

How many days => 4

Enter day, month, year, temperature => 29 11 2018 15.6

Enter day, month, year, temperature => 30 11 2018 8.7

Enter day, month, year, temperature => 1 12 2018 3.1

Enter day, month, year, temperature => 2 12 2018 3.5

Lowest temperature = 3.1C, Day 1/12/2018

Average temperature = 7.7 C

In: Computer Science

Soccer League Java homework assignment. Below is the assignment brief. It requires to have the necessary...

Soccer League

Java homework assignment.

Below is the assignment brief.

It requires to have the necessary java classes created: 'Team', 'Game', 'Schedule', and 'Main'.

All attributes are private, and getters/setters are created.

The sample output should be as stated below.

Overview

It has been a brutally cold and snowy winter. None of your friends have wanted to play soccer. But now that spring has arrived, another season of the league can begin. Your challenge is to write a program that models a soccer league and keeps track of the season’s statistics. There are 4 teams in the league. Matchups are determined at random. 2 games are played every Tuesday, which allows every team to participate weekly. There is no set number of games per season. The season continues until winter arrives. The league is very temperature sensitive. Defenses are sluggish on hot days. Hotter days allow for the possibility of more goals during a game. If the temperature is freezing, no games are played that week. If there are 3 consecutive weeks of freezing temperatures, then winter has arrived, and the season is over.

Task

Write a program that models a soccer league and keeps track of the season’s statistics. Carefully consider what data should be stored in an array and what data should be stored in an Array List. Design classes with fields and methods based on the description of the league. You will also need a test class that contains the main method. All fields must be private. Provide any necessary getters and setters.

Team

Each team has a name. The program should also keep track of each team’s win-total, loss-total, tie total, total goals scored, and total goals allowed. Create an array of teams that the scheduler will manage. Print each team’s statistics when the season ends.

Game

In a game, it is important to note each team’s name, each team’s score, and the temperature that day. Number each game with an integer ID number. This number increases as each game are played. Keep track of every game played this season. This class stores an Array List of all games as a field. Your program should determine scores at random. The maximum number of goals any one team can score should increase proportionally with the temperature. But make sure these numbers are somewhat reasonable. When the season ends, print the statistics of each game. Print the hottest temperature and average temperature for the season.

Schedule

Accept user input through a JOptionPane or Scanner. While the application is running, ask the user to input a temperature. The program should not crash because of user input. If it is warm enough to play, schedule 2 games. Opponents are chosen at random. Make sure teams are not scheduled to play against themselves. If there are 3 consecutive weeks of freezing temperatures, the season is over.

Sample Output:

run:

Too cold to play.

Too cold to play.

Too cold to play.

Season is over

*********RESULTS*********

Team 1

Wins: 1, Losses: 1, Ties:0

Points Scored: 9, Points Allowed: 9

Team 2 Wins: 1, Losses: 1, Ties:0

Points Scored: 8, Points Allowed: 8

Team 3 Wins: 0, Losses: 1, Ties:1

Points Scored: 6, Points Allowed: 9

Team 4 Wins: 1, Losses: 0, Ties:1

Points Scored: 8, Points Allowed: 5

Game #1

Temperature: 90

Away Team: Team 2, 4

Home Team: Team 4, 7

Game #2

Temperature: 90

Away Team: Team 1, 8

Home Team: Team 3, 5

Game #3 Temperature: 35

Away Team: Team 1, 1

Home Team: Team 2, 4

Game #4

Temperature: 35

Away Team: Team 3, 1

Home Team: Team 4, 1

Hottest Temp: 90

Average Temp:62.5

In: Computer Science

java Introduction: Runtime complexity is an issue when determining which algorithms we should use. Some algorithms...

java

Introduction:

Runtime complexity is an issue when determining which algorithms we should use. Some algorithms are easy to implement but run too slowly to be useful. Knowing the advantages and disadvantages of different algorithms helps in determining the best solution to a problem.

Description:

You are to implement two different sorting algorithms and count the number of steps involved with the sort routine (the comparisons and moving positions). Every time a comparison or move is made you should count it.

You have been given a data file with text. You must read through the file to determine the number of words in it, then create an array big enough to hold the values. Once the array is built you need to reread the file to store the strings into the array.

You must implement Insertion Sort and Quick Sort. These sorts must take an array of strings and sort them in ascending order. When sorted you must display each UNIQUE value and the number of times it appears in the array. At the end you must print out which sort was used and how many steps it took to complete.

You must keep asking the user which sort to use until the Exit symbol is entered. Remember that passing an array to a method will modify the original array. You must copy the array so you do not lose the order of the original and just sort the copy.

Program:

You must create a program called p6.java. Everything can be done inside of this file if done within the same class. If you wish to create additional classes to help, you must have them in separate .java files.

Input:

There is an input file called p6.dat were each line contains a name.

p6.dat content:

I AM SAM. I AM SAM. SAM-I-AM. THAT SAM-I-AM! THAT SAM-I-AM! I DO NOT LIKE THAT SAM-I-AM! DO WOULD YOU LIKE GREEN EGGS AND HAM? I DO NOT LIKE THEM,SAM-I-AM. I DO NOT LIKE GREEN EGGS AND HAM. WOULD YOU LIKE THEM HERE OR THERE? I WOULD NOT LIKE THEM HERE OR THERE. I WOULD NOT LIKE THEM ANYWHERE. I DO NOT LIKE GREEN EGGS AND HAM. I DO NOT LIKE THEM, SAM-I-AM. WOULD YOU LIKE THEM IN A HOUSE? WOULD YOU LIKE THEN WITH A MOUSE? I DO NOT LIKE THEM IN A HOUSE. I DO NOT LIKE THEM WITH A MOUSE. I DO NOT LIKE THEM HERE OR THERE. I DO NOT LIKE THEM ANYWHERE. I DO NOT LIKE GREEN EGGS AND HAM. I DO NOT LIKE THEM, SAM-I-AM. WOULD YOU EAT THEM IN A BOX? WOULD YOU EAT THEM WITH A FOX? NOT IN A BOX. NOT WITH A FOX. NOT IN A HOUSE. NOT WITH A MOUSE. I WOULD NOT EAT THEM HERE OR THERE. I WOULD NOT EAT THEM ANYWHERE. I WOULD NOT EAT GREEN EGGS AND HAM. I DO NOT LIKE THEM, SAM-I-AM. WOULD YOU? COULD YOU? IN A CAR? EAT THEM! EAT THEM! HERE THEY ARE. I WOULD NOT, COULD NOT, IN A CAR. YOU MAY LIKE THEM. YOU WILL SEE. YOU MAY LIKE THEM IN A TREE! I WOULD NOT, COULD NOT IN A TREE. NOT IN A CAR! YOU LET ME BE. I DO NOT LIKE THEM IN A BOX. I DO NOT LIKE THEM WITH A FOX. I DO NOT LIKE THEM IN A HOUSE. I DO NOT LIKE THEM WITH A MOUSE. I DO NOT LIKE THEM HERE OR THERE. I DO NOT LIKE THEM ANYWHERE. I DO NOT LIKE GREEN EGGS AND HAM. I DO NOT LIKE THEM, SAM-I-AM. A TRAIN! A TRAIN! A TRAIN! A TRAIN! COULD YOU, WOULD YOU ON A TRAIN? NOT ON TRAIN! NOT IN A TREE! NOT IN A CAR! SAM! LET ME BE! I WOULD NOT, COULD NOT, IN A BOX. I WOULD NOT, COULD NOT, WITH A FOX. I WILL NOT EAT THEM IN A HOUSE. I WILL NOT EAT THEM HERE OR THERE. I WILL NOT EAT THEM ANYWHERE. I DO NOT EAT GREEM EGGS AND HAM. I DO NOT LIKE THEM, SAM-I-AM. SAY! IN THE DARK? HERE IN THE DARK! WOULD YOU, COULD YOU, IN THE DARK? I WOULD NOT, COULD NOT, IN THE DARK. WOULD YOU COULD YOU IN THE RAIN? I WOULD NOT, COULD NOT IN THE RAIN. NOT IN THE DARK. NOT ON A TRAIN. NOT IN A CAR. NOT IN A TREE. I DO NOT LIKE THEM, SAM, YOU SEE. NOT IN A HOUSE. NOT IN A BOX. NOT WITH A MOUSE. NOT WITH A FOX. I WILL NOT EAT THEM HERE OR THERE. I DO NOT LIKE THEM ANYWHERE! YOU DO NOT LIKE GREEN EGGS AND HAM? I DO NOT LIKE THEM, SAM-I-AM. COULD YOU, WOULD YOU, WITH A GOAT? I WOULD NOT, COULD NOT WITH A GOAT! WOULD YOU, COULD YOU, ON A BOAT? I COULD NOT, WOULD NOT, ON A BOAT. I WILL NOT, WILL NOT, WITH A GOAT. I WILL NOT EAT THEM IN THE RAIN. NOT IN THE DARK! NOT IN A TREE! NOT IN A CAR! YOU LET ME BE! I DO NOT LIKE THEM IN A BOX. I DO NOT LIKE THEM WITH A FOX. I WILL NOT EAT THEM IN A HOUSE. I DO NOT LIKE THEM WITH A MOUSE. I DO NOT LIKE THEM HERE OR THERE. I DO NOT LIKE THEM ANYWHERE! I DO NOT LIKE GREEN EGGS AND HAM! I DO NOT LIKE THEM, SAM-I-AM. YOU DO NOT LIKE THEM. SO YOU SAY. TRY THEM! TRY THEM! AND YOU MAY. TRY THEM AND YOU MAY, I SAY. SAM! IF YOU LET ME BE, I WILL TRY THEM. YOU WILL SEE. SAY! I LIKE GREEN EGGS AND HAM! I DO! I LIKE THEM, SAM-I-AM! AND I WOULD EAT THEM IN A BOAT. AND I WOULD EAT THEM WITH A GOAT... AND I WILL EAT THEM, IN THE RAIN. AND IN THE DARK. AND ON A TRAIN. AND IN A CAR. AND IN A TREE. THEY ARE SO GOOD, SO GOOD, YOU SEE! SO I WILL EAT THEM IN A BOX. AND I WILL EAT THEM WITH A FOX. AND I WILL EAT THEM IN A HOUSE. AND I WILL EAT THEM WITH A MOUSE. AND I WILL EAT THEM HERE AND THERE. SAY! I WILL EAT THEM ANYWHERE! I DO SO LIKE GREEN EGGS AND HAM! THANK YOU! THANK YOU, SAM-I-AM.

Output:

(S)election Sort

(Q)uick Sort

(E)xit

Enter choice: Q

A : 56 frequency.

AM : 2 frequency.

AND : 25 frequency.

ANYWHERE! : 3 frequency.

ANYWHERE. : 5 frequency.

ARE : 1 frequency.

ARE. : 1 frequency.

BE! : 2 frequency.

BE, : 1 frequency.

BE. : 1 frequency.

BOAT. : 2 frequency.

BOAT? : 1 frequency.

BOX. : 6 frequency.

BOX? : 1 frequency.

CAR! : 3 frequency.

CAR. : 3 frequency.

CAR? : 1 frequency.

COULD : 14 frequency.

DARK! : 2 frequency.

DARK. : 3 frequency.

DARK? : 2 frequency.

DO : 36 frequency.

DO! : 1 frequency.

EAT : 23 frequency.

EGGS : 11 frequency.

FOX. : 6 frequency.

FOX? : 1 frequency.

GOAT! : 1 frequency.

GOAT. : 1 frequency.

GOAT... : 1 frequency.

GOAT? : 1 frequency.

GOOD, : 2 frequency.

GREEM : 1 frequency.

GREEN : 10 frequency.

HAM! : 3 frequency.

HAM. : 6 frequency.

HAM? : 2 frequency.

HERE : 11 frequency.

HOUSE. : 7 frequency.

HOUSE? : 1 frequency.

I : 69 frequency.

IF : 1 frequency.

IN : 40 frequency.

LET : 4 frequency.

LIKE : 44 frequency.

MAY : 2 frequency.

MAY, : 1 frequency.

MAY. : 1 frequency.

ME : 4 frequency.

MOUSE. : 6 frequency.

MOUSE? : 1 frequency.

NOT : 67 frequency.

NOT, : 15 frequency.

ON : 6 frequency.

OR : 8 frequency.

RAIN. : 3 frequency.

RAIN? : 1 frequency.

SAM! : 2 frequency.

SAM, : 1 frequency.

SAM-I-AM! : 4 frequency.

SAM-I-AM. : 9 frequency.

SAM. : 2 frequency.

SAY! : 3 frequency.

SAY. : 2 frequency.

SEE! : 1 frequency.

SEE. : 3 frequency.

SO : 5 frequency.

THANK : 2 frequency.

THAT : 3 frequency.

THE : 11 frequency.

THEM : 40 frequency.

THEM! : 4 frequency.

THEM, : 10 frequency.

THEM,SAM-I-AM. : 1 frequency.

THEM. : 3 frequency.

THEN : 1 frequency.

THERE. : 8 frequency.

THERE? : 1 frequency.

THEY : 2 frequency.

TRAIN! : 5 frequency.

TRAIN. : 2 frequency.

TRAIN? : 1 frequency.

TREE! : 3 frequency.

TREE. : 3 frequency.

TRY : 4 frequency.

WILL : 18 frequency.

WITH : 18 frequency.

WOULD : 27 frequency.

YOU : 23 frequency.

YOU! : 1 frequency.

YOU, : 8 frequency.

YOU? : 2 frequency.

Quicksort finished in 12000 steps.

Hints:

Note that depending on implementation the number of steps you will have is different from others.

Use appropriate software design techniques, and implement the class methods with Java constructs for I/O, declarations, and calculations.

Build your program in steps (i.e., get the input and output working, then add the functions, etc.). Emphasize functionality first, then add the advanced features.

data:

Remember that you must pass the data file name in as a command line argument.

In: Computer Science

What are some of the potential sources of risk in a systems analysis and design project?...

What are some of the potential sources of risk in a systems analysis and design project? How does the project manager cope with these risks throughout the duration of the project?

In: Computer Science

Using a vector of integers that you define. Write a C++ program to run a menu...

Using a vector of integers that you define.

Write a C++ program to run a menu driven program with the following choices:

1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit

Make sure your program conforms to the following requirements:

2. Write a function called getValidAge that allows a user to enter in an integer and loops until a valid number that is >= 0 and < 120 is entered. It returns the valid age. (5 points).

3. Write a function called displayAges that takes in a vector of integers as a parameter and displays the ages in the format in the sample run below. (10 points).

4. Write a function called AddAge that takes in a vector of integers by reference as a parameter, asks the user to input a valid age, and adds it to the vector of integers . (15 points).

5. Write a function called getAverageAge that takes in a vector of integers as a parameter, computes, and returns the average age. (15 points).

6. Write a function called getYoungestAge that takes in a vector of integers as a parameter, computes, and returns the youngest age. (15 points).

7. Write a function called getNumStudentsVote that takes in a vector of integers as a parameter, computes, and returns the number of ages in the vector that are >= 18. (15 points).

8. Write a function called RemoveStudentsLessThanSelectedAge that takes in a vector of integers as a parameter, asks the user for an age, creates a new vector of integers that only contains the ages in the parameter vector which are >= the age selected by the user and returns the new vector. (20 points).

9. Add comments wherever necessary. (5 points)

NOTE: You must take care of the case when the vector is empty and an operation is being performed on it. In such cases the program should display a 0 for the given result.

Sample Runs:

NOTE: not all possible runs are shown below.

Welcome to the students age in class program!
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:

1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..3
Average age = 0
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..4
Youngest age = 0
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..5
Number of students who can vote = 0
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..6
Please enter in the age...
5
Students removed
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
4
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
24
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
18
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
12
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
4 24 18 12
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..3
Average age = 14
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..4
Youngest age = 4
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..5
Number of students who can vote = 2
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..6
Please enter in the age...
15
Students removed
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
24 18
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..3
Average age = 21
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..4
Youngest age = 18
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..5
Number of students who can vote = 2
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..-8
Select an option (1..7)..8
Select an option (1..7)..1
Student ages:
24 18
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
-8
Please enter in a valid age (1-120) ...
130
Please enter in a valid age (1-120) ...
55
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
24 18 55
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..7

Process finished with exit code 0

In: Computer Science