Questions
wite a program in C to print a right and left pointing arrow pattern using '#'...

wite a program in C to print a right and left pointing arrow pattern using '#' symbol. Do so within 10 lines i.e upper half of the occupies 5 lines and lower half occupies other 5 lones.

User will enter 'R' or'r' for printing right pointing arrow. 'l' or 'L' for left pointing arrow.'k'' for invalid option.

You must use if-else and while loop for do this.

In: Computer Science

Problem: On an ARM processor using big endian format, given the following memory map and [R1]...

Problem: On an ARM processor using big endian format, given the following memory map and [R1] = 0xA10E0C2D, [R2] = 0x00000060, [R3] = 0x00000002, [R4] = 0x0000000C, predict [R1] and [R2] and draw the updated memory map after an ARM data transfer instruction is executed in EACH case. (hint: (1) in this map, each memory location is a word long and occupies 4 bytes; also you only need to draw the section of the memory including the changed word and its address; (2) these instructions are NOT executed one after the other one; instead, each instruction starts with the initial conditions given in the statement.)

0x6C [0x78092A7B]

0x68 [0x56AB8CEF]

0x64 [0x3490AB02]

0x60 [0x902E8C9A]

(1) LDRH R1, [R2, R4]

(2) STRB R1, [R2]

In: Computer Science

Complete the task below C++ This header file declares the Comp315Array Class **************************/ //Include the libraries...

Complete the task below C++

This header file declares the Comp315Array Class

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

//Include the libraries
#include <iostream> //Allow the use of cin and cout
//Declare namespace std for using cin and cout
using namespace std;

//Class declaration
class Comp315Array{
        
        //Public members
        public:
                /****************
                Default Constructor
                Task: assign 0 to the array size 
                *********/
                Comp315Array();

                /****************
                        Constructor
                        Task: Define an int array of size n 
                *********/
                Comp315Array(int n);
                
                /*****************
                        getSize method
                        Task: return the array size
                ******************/
                int getSize();
                
                /*****************
                        setValue method
                        Task: set array value in position p
                ******************/
                void setValue(int p, int val);
                
                /*****
                        sum method
                        Task: compute the sum of the n elements in the array
                        params:
                        @returns
                                sum of elements
                *******/
                int sum();
                
                /*****
                        sum method
                        Task: compute the sum of the elements in the array from position i to position j
                        @returns
                                sum of elements from position i to position j
                *******/
                int sum(int i, int j);
                
                /*****
                        greatest method
                        Task: returns the greatest element in the array
                        @returns
                                value of the greatest element in the array
                *******/
                int greatest();
                
                /*****
                        lowest method
                        Task: returns the lowest element in the array
                        @returns
                                value of the lowest element in the array
                *******/
                int lowest();

                /*****
                        average method
                        Task: the average of elements in the array
                        @returns
                                the average of elements in the array
                *******/
                double averageValue();

                /******
                        occurencesCount method
                        Task: count the number of occurrences in the array of a target value
                        params
                                 targetVal: target value
                        @returns
                                number of occurrences of the target value in the array
                *********/
                int occurencesCount(int targetVal);
                
                /******
                        firstOccurence method
                        Task: returns the position of the first occurrence of a target value
                        params
                                 targetVal: target value
                        @returns
                                position of the first occurrence of target value in the array
                                        if the target value is not in the array, the method must return a -1
                *********/
                int firstOccurence(int targetVal);


                /******
                        printArray method
                        Task: print elements in the array
                        @returns
                                
                *********/
                void printElements();

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

                        Destructor
                ******/
                ~Comp315Array();


                


        //Private members
        private:
                //array size
                int arraySize;
                
                //actual array
                int *actualArray;
                
};

**************************/
This file implements the Comp315Array Class



//Include the header file
#include "Comp315Array.h" //Allow the use of cin and cout

                
        /****************
                Default Constructor
                Task: assign 0 to the array size 
        *********/
        Comp315Array::Comp315Array()
        {
                arraySize = 0;
        }
        
        /****************
                Destructor  
        *********/
        Comp315Array::~Comp315Array()
        {
                actualArray=0;
        }

        /****************
                Constructor
                Task: Define an int array of size n 
        *********/
        Comp315Array::Comp315Array(int n)
        {
                actualArray= new int[n];
                arraySize = n;
        }
        
        
        
        /*****************
                getSize method
                Task: return the array size
        ******************/
        int Comp315Array::getSize(){
                return arraySize;
        }
        

        /*****************
                setValue method
                Task: set array value in position p
        ******************/
        void Comp315Array::setValue(int p, int actualValue){
                        actualArray[p]=actualValue;
        }

        
        /*****
                sum method
                Task: compute the sum of the n elements in the array
                params:
                @returns
                        sum of elements
        *******/
        int Comp315Array::sum(){
                int res=0;
                
                return res;
        }
        
        /*****
                sum method
                Task: compute the sum of the elements in the array from position i to position j
                @returns
                        sum of elements from position i to position j
        *******/
        int Comp315Array::sum(int i, int j){
                int res=0;
                
                return res;
        }
        
        /*****
                greatest method
                Task: returns the greatest element in the array
                @returns
                        value of the greatest element in the array
        *******/
        int Comp315Array::greatest(){
                int res=actualArray[0];
                
                return res;
        }
        
        /*****
                lowest method
                Task: returns the lowest element in the array
                @returns
                        value of the lowest element in the array
        *******/
        int Comp315Array::lowest(){
                int res=actualArray[0];
                
                return res;
        }

        /*****
                average method
                Task: the average of elements in the array
                @returns
                        the average of elements in the array
        *******/
        double Comp315Array::averageValue(){
                int res=0;
                
                return res;
        }

        /******
                occurencesCount method
                Task: count the number of occurrences in the array of a target value
                params
                         targetVal: target value
                @returns
                        number of occurrences of the target value in the array
        *********/
        int Comp315Array::occurencesCount(int targetVal){
                int res=0;
                
                return res;
        }
        
        /******
                firstOccurence method
                Task: returns the position of the first occurrence of a target value
                params
                         targetVal: target value
                @returns
                        position of the first occurrence of target value in the array
                                if the target value is not in the array, the method must return a -1
        *********/
        int Comp315Array::firstOccurence(int targetVal){
                int res=-1;
                
                return res;
        }
        
/******
        printArray method
        Task: print elements in the array
        @returns
                
        *********/
        void Comp315Array::printElements(){
                for(int i=0;i<arraySize; i++){
                        cout<<actualArray[i]<<endl;
                }       
        }
**************************/ 
This file implements the Comp315Array Class


//Include the header file
#include "Comp315Array.h" //Allow the use of cin and cout


int menu()
{
        int op;
        
        op=0;
        while (op==0 || op>10)
        {
                cout<<"***********************************"<<endl;
                cout<<"Select one of the following options"<<endl;
                cout<<"***********************************"<<endl;
                cout<<"   1. Introduce array elements"<<endl;
                cout<<"   2. Compute elements sum"<<endl;
                cout<<"   3. Compute elements sum in a selected range"<<endl;
                cout<<"   4. Compute elements average value"<<endl;
                cout<<"   5. Find the greatest element"<<endl;
                cout<<"   6. Find the lowest element"<<endl;
                cout<<"   7. Count occurrences of an element"<<endl;
                cout<<"   8. Find the first occurrence of an element"<<endl;
                cout<<"   9. Print elements"<<endl;
                cout<<"   10. Exit"<<endl;
                cout<<"***********************************"<<endl;
                cin>>op;
        }
        cout<<"Selected option"<<op<<endl<<endl;
        return op;
}

                
int main(){
        
        int size, op, val;
        Comp315Array cArray;
        
        cout<<"Array size? ";
        cin>>size;
        
        cArray = Comp315Array(size);
        
        
        do{
                op=menu();      
                
                switch (op) {
                        case 1: for (int i=0; i<size; i++)
                                {
                                        cout<<"Element "<<i<<": ";
                                        cin>>val;
                                        cArray.setValue(i,val);
                                }
                                break;

                        case 2: cout<<"The total sum is "<< cArray.sum()<<endl;
                                break;
                        case 3: 
                                int initVal, endVal;
                                cout<<"Initial position: ";
                                cin>>initVal;
                                cout<<"Final position: ";
                                cin>>endVal;      
                                cout<<"The total sum is "<< cArray.sum(initVal, endVal)<<endl;
                                break;                  

                        case 4: cout<<"The aveage value is "<< cArray.averageValue()<<endl;
                                break;
                        case 5: cout<<"The greatest value is "<< cArray.greatest()<<endl;
                                break;
                        case 6: cout<<"The lowest value is "<<cArray.lowest()<<endl;
                                break;
                        case 7: cout<<"Target value: ";
                                cin>>val;
                                cout<<"Number of occurrences: " << cArray.occurencesCount(val) <<endl;
                                break;
                        case 8: cout<<"Target value: ";
                                cin>>val;
                                cout<<"The first occurrence is in position " << cArray.firstOccurence(val) <<endl;
                                break;
                        case 9: cArray.printElements();
                                break;
                                        
                }


        }while(op!=10);
        
        cout<<"Goodbye!"<<endl;

        return 0;
}

In: Computer Science

A digital computer has a memory unit with 32 bits per word. The instruction set consists...

A digital computer has a memory unit with 32 bits per word. The instruction set consists of 122 different operations. All instructions have an operation code part (opcode) and an address part (allowing for only one address). Each instruction is stored in one word of memory.

  1. a) How many bits are needed for the opcode?

  2. b) How many bits are left for the address part of the instruction?

  3. c) What is the maximum allowable size for memory?

  4. d) What is the largest unsigned binary number that can be accommodated in one word of memory?

In: Computer Science

Im in a java class and having trouble with assigning the seat to a specific number...

Im in a java class and having trouble with assigning the seat to a specific number from the array.. Below are the instructions I was given and then the code that I have already.  

ITSE 2321 – OBJECT-ORIENTED PROGRAMMING JAVA Program 8 – Arrays and ArrayList

A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You are to write an application to assign seats on flight of the airline’s only plane (capacity: 10 seats). Your application should display the following alternatives: "Please type 1 for First Class" and "Please type 2 for Economy." If the user types 1, your application should assign a seat in the first-class section (seats 1 – 5). If the user types 2, your application should assign a seat in the economy section (seats 6 – 10). Your application should then display a boarding pass indicating the person’s seat number and whether it’s in the first-class or economy section of the plane. Use a one-dimensional array of primitive type boolean to represent the seating chart of the plane. Initialize all the elements of the array to false to indicate that all the seats are empty. As each is assigned, set the corresponding element of the array to true to indicate that the seat is on longer available. Your application should never assign a seat that has already been assigned. When the economy section is full, your application should ask the person if it’s acceptable to be placed in the first-class section (and vice versa). If yes, make the appropriate seat assignment. If no, display the message "Next flight leaves in 3 hours." End the program when all the ten seats on the plane have been assigned.

No input, processing or output should happen in the main method. All work should be delegated to other non-static methods. Include the recommended minimum documentation for each method. See the program one template for more details.

Run your program, with your own data, and copy and paste the output to a file. Create a folder named, fullname_program8. Copy your source code and the output file to the folder. Zip the folder and upload it to Blackboard.

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package airlineapp;


import java.util.Scanner;

/**
*
* @author user1
*/
public class AirlineApp {
int num;
int i;
int counter = 0;
int [] seatNum = new int[11];

  
public static void main(String[] args) {
AirlineApp application = new AirlineApp();
application.userInput();
application.seatChart();
  
//create the array
  
  
// TODO code application logic here
}

public void userInput(){
Scanner input = new Scanner(System.in);
System.out.print("Please type 1 for first class and press 2 for economy: ");

//gets the input from the user and saves it as num to perform the rest
//of the aplication
num = input.nextInt();

}

public void seatChart(){
  
for(int counter = 0; counter < seatNum.length; counter++){
if(num != 2 && counter < 6 )
counter = counter + 1;
  
  
}
  
  
  
  
}
  
  
}


  
  
  
  
  
  
  

  
  
  
  

In: Computer Science

Compare the file storage of two types of cell phones, such as an iPhone and an...

Compare the file storage of two types of cell phones, such as an iPhone and an Android phone. Research the amount of system software that occupies main memory after the phone is completely powered on. If the amount of storage used by the system files are substantially different, explain why that may be the case, such as platform issues, features, and so on. Cite your sources.

Cell phone configuration doesn't matter. Can pick any two types of cell phone.

In: Computer Science

What is a data dictionary? How is it useful and to whom? When should you consider...

What is a data dictionary? How is it useful and to whom? When should you consider including one in a project?

In: Computer Science

"Gambling Greg" Assignment Outcomes: Demonstrate the ability to create and use structs Demonstrate the ability to...

"Gambling Greg" Assignment

Outcomes:

  • Demonstrate the ability to create and use structs
  • Demonstrate the ability to create and use menus
  • Demonstrate the ability to create and use an array of structs
  • Demonstrate the ability to generate and use random numbers

Program Specifications:

Assume that gambling Greg often goes to the Dog Racing Track. Greg loves to bet on the puppies. In each race Greg will place a wager and pick a dog. The dog information will be stored in a structure name DOG as follows:

Name, amount to pay out if Greg wins, and the odds of this dog winning the race.

The program should have the following menu:

[G]amble

[R]esults of All Races

[L]eave the Dog Track

If Greg selects [G] the program will ask Greg for his wager and allow Greg to pick a dog from a list. The program will then run the race. The result will be shown to Greg. The results of the race will be stored for future use.

If Greg selects [R] the program will show Greg the results of all previous races entered during this run of the program.

If Greg selects [L] the program will end.

The dogs:

You will create 9 different dogs. See below:

Dog Name

Payout

Odds of Winning

You name the dogs

2 to 1

40%

5 to 1

10%

10 to 1

8%

15 to 1

6%

50 to 1

1%

20 to 1

4%

10 to 1

8%

5 to 1

10%

3 to 1

13%

In: Computer Science

As you know, the number of days in each month of our calendar varies: • February...

As you know, the number of days in each month of our calendar varies: • February has 29 days in a leap year, or 28 days otherwise. • April, June, September, and November have 30 days. • All other months have 31 days. Usually, years that are divisible by 4 (e.g., 2008, 2012, 2016) are leap years. However, there’s an exception: years that are divisible by 100 (e.g., 2100, 2200) are not leap years. But there’s also an exception to that exception: years that are divisible by 400 (e.g., 1600, 2000) are leap years.
Within your Lab3HW folder, write a program named DaysInMonth.java that asks the user to enter a month (1-12) and year (1000-3000). Your program should then show the number of days in that month. If the user enters a month or year beyond the specified ranges, show an appropriate error message.
Here are some examples of what your completed program might look like when you run it. Underlined parts indicate what you type in as the program is running.
Example 1
Enter month (1-12): 0 Enter year (1000-3000): 2001 Error - month and/or year out of bounds.
1
Example 2
Enter month (1-12): 2 Enter year (1000-3000): 2016 2/2016 contains 29 days.
Example 3
Enter month (1-12): 2 Enter year (1000-3000): 2900 2/2900 contains 28 days.

In: Computer Science

Problem Write in drjava is fine. Using the classes from Assignment #2, do the following: Modify...

Problem

Write in drjava is fine.

Using the classes from Assignment #2, do the following:

  1. Modify the parent class (Plant) by adding the following abstract methods:
    1. a method to return the botanical (Latin) name of the plant
    2. a method that describes how the plant is used by humans (as food, to build houses, etc)
  2. Add a Vegetable class with a flavor variable (sweet, salty, tart, etc) and 2 methods that return the following information:
    1. list 2 dishes (meals) that the vegetable can be used in
    2. where this vegetable is grown

The Vegetable class should have the usual constructors (default and parameterized), get (accessor) and set (mutator) methods for each attribute, and a toString method

Child classes should call parent methods whenever possible to minimize code duplication.

The driver program must test all the methods in the Vegetable class, and show that the new methods added to the Plant class can be called by each of the child classes. Include comments in your output to describe what you are testing, for example   System.out.println(“testing Plant toString, accessor and mutator”);. Print out some blank lines in the output to make it easier to read and understand what is being output.

Assignment Submission:

Submit a print-out of the Plant and Vegetable classes, the driver file and a sample of the output. Also include a UML diagram of the classes involved. (Use tables in Word to create the various classes. Remember to use the correct arrows between the classes)

Marking Checklist

  1. Does EACH class have all the usual methods?
  2. Are all methods in EACH class tested, including child objects calling inherited parent methods?
  3. Does the child class call the parent’s constructor?
  4. Does the child class override the parent’s toString?
  5. Does the output produced have lots of comments explaining what is being output?
  6. Does each class, and the output, have blank lines and appropriate indenting to make them more readable?
  7. public class Plant
  8. private String name;
  9. private String lifespan;

class Plant{
    String name;
    String lifeSpan;

    //Default Constructor
    public Plant(){

    }

    //Parametrized Constructor
    public Plant(String name,String lifeSpan){
        this.name=name;
        this.lifeSpan=lifeSpan;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLifeSpan() {
        return lifeSpan;
    }

    public void setLifeSpan(String lifeSpan) {
        this.lifeSpan = lifeSpan;
    }

    public String toString(){
        return "\n\tName:"+name+"\n\tLifeSpan:"+lifeSpan;
    }
}

class Tree extends Plant{
    float height;

    //Default Constructor
    public Tree(){

    }

    //Parametrized Constructor
    public Tree(float height,String name,String lifeSpan){
        super(name,lifeSpan); //Super Class Constructor
        this.height=height;
    }

    public float getHeight() {
        return height;
    }

    public void setHeight(float height) {
        this.height = height;
    }

    public String toString(){
        return "\n\t"+super.toString()+"\n\tHeight:"+height;
    }

}

class Flower extends Plant{
    String color;

    //Default Constructor
    public Flower(){

    }

    //Parametrized Constructor
    public Flower(String color,String name,String lifeSpan){
        super(name,lifeSpan); //Super Class Constructor
        this.color=color;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String toString(){
        return "\n\t"+super.toString()+"\n\tColor:"+color;
    }
}


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

        System.out.println("\n\nPlant DETAILS\n");
        Plant plant=new Plant();
        System.out.println("Testing Plant Setter and Getter and toString Methods");
        plant.setName("Rose");
        plant.setLifeSpan("2Years");
        System.out.println("Plant Name:"+plant.getName());
        System.out.println("Plant LifeSpan:"+plant.getLifeSpan());
        System.out.println("Plant toString:"+plant.toString());

        System.out.println("\n\nTREE DETAILS\n");
        Tree tree=new Tree();
        System.out.println("Testing Tree Setter and Getter and toString Methods");
        tree.setName(plant.getName());
        tree.setLifeSpan(plant.getLifeSpan());
        tree.setHeight(3.565f);
        System.out.println("Tree Name:"+tree.getName());
        System.out.println("Tree Height:"+tree.getHeight());
        System.out.println("Tree LifeSpan"+tree.getLifeSpan());
        System.out.println("Tree toString:"+tree.toString());

        System.out.println("\n\nFlower DETAILS\n");
        Flower flower=new Flower();
        System.out.println("Testing Flower Setter and Getter and toString Methods");
        flower.setName("Rose Flower");
        flower.setLifeSpan("2days");
        flower.setColor("Red");
        System.out.println("Flower Name:"+flower.getName());
        System.out.println("Flower Lifespan:"+flower.getLifeSpan());
        System.out.println("Flower Color:"+flower.getColor());
        System.out.println("Flower toString:\n"+flower.toString());
    }
}

In: Computer Science

Modify the following C++ program to count the number of correct and incorrect responses typed by...

Modify the following C++ program to count the number of correct and incorrect responses typed by the student. After the student types 5 answers, your program should calculate the percentage of correct responses. If the percentage is lower than 75 percent, your program should print “Please ask for extra help” and then terminate. If the percentage is 75 percent or higher, your program should print “Good work!” and then terminate. The program is as follows:

#include<iostream>

#include<iomanip>

#include<cstdlib>

#include<time.h>

using namespace std;

int main()
{
const int no_runs = 5;
int run, n1,n2,answer;

srand((unsigned int)time(NULL));

for(run = 0;run<no_runs;run++)
{
n1 = rand()%9 + 1;
n2 = rand()%9 +1;
while(true)
{
cout<<"What is the product of "<<n1<<" and "<<n2<<": ";
cin>>answer;
if(answer==n1*n2)
break;
cout<<"No. Please try again."<<endl;
}
cout<<"Very good!"<<endl;
}
system("pause");
return 0;
}

In: Computer Science

Create a table in C of conversion from Celsius to Rankin. Allow the user to enter...

Create a table in C of conversion from Celsius to Rankin. Allow the user to enter the starting temperature and increment between lines. Print 25 lines in the table.
Rankin = 9/5(Celsius + 273.15)

In: Computer Science

*******FOR A BIG THUMBS UP******** ------INSTRUCTIONS--------- Coding standards note: The coding standards are in a document...

*******FOR A BIG THUMBS UP********

------INSTRUCTIONS---------

Coding standards note: The coding standards are in a document in a D2L module titled Coding Standards. See Grading Criteria for points lost if not followed.

Competencies being graded:

  1. Ability to implement a HashMap
  2. Ability to populate and print from a HashMap
  3. Ability to write items from a HashMap
  4. Read and write a binary file using ObjectInputStream and ObjectOutputStream
  5. Ability to read an English language problem description and design a multi class solution in Java
  6. Ability to follow given coding standards- in D2L content under Coding Standards.

Problem Statement:

Create a program that reads in the file people.dat from Homework 2. (Yes, you can use the code from Homework 1). Please make sure to include Person.java in your submission.

Implement your own HashMap implementation. You may use the HashMap example provided in the notes, but you MUST modify it to handle Person objects only and bring it completely up to coding standards to receive all points. You MAY NOT use java.util.HashMap or java.util.TreeMap in this problem.

After reading in the Person objects, store the Personobjects into your HashMap implementation using the unique ID as the key to the map rather than the ArrayList used in Homework 2. Then print the Person objects from the HashMap in a user friendly fashion. You may use iterator or for-each loop-> DO NOT JUST System.out.println THE HASHMAP- ITERATE THROUGH IT.   Hint: Modify your toString in Person to get a nice looking output.

------people.dat---------

¬í sr PersonM”fò(Ÿ# I idNumL cityt Ljava/lang/String;L    firstNameq ~ L lastNameq ~ xp t Bufordt Nanat Agyemansq ~ t Dulutht Josepht Andersonsq ~ t Lawrencevillet Kylet Brookssq ~ t Daculat Joshuat    Broughtonsq ~ t Lilburnt Demetrit Clarksq ~ t
Snellvillet Davidt Edwardssq ~ t Atlantat Jonit Elshanisq ~ t Decaturt Jacobt Fagan

------peopleFile.txt-------

Nana
Agyeman
Buford
1
Joseph
Anderson
Duluth
2
Kyle
Brooks
Lawrenceville
3
Joshua
Broughton
Dacula
4
Demetri
Clark
Lilburn
5
David
Edwards
Snellville
6
Joni
Elshani
Atlanta
7
Jacob
Fagan
Decatur
8

--------Person.java-----------

import java.io.Serializable;
public class Person implements Serializable
{
   public String firstName;
   public String lastName;
   public int idNum;
   public String city;

   /**
   * Default constructor used to create empty attributes
   */
   public Person()
   {
       firstName = "";
       lastName = "";
       idNum = 0;
       city = "";
   }

   /**
   * @param firstName
   * @param lastName
   * @param idNum
   * @param city
   */
   public Person(String firstName, String lastName, int idNum, String city)
   {
       this.firstName = firstName;
       this.lastName = lastName;
       this.idNum = idNum;
       this.city = city;
   }

   /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString()
   {
       return firstName + " " + lastName ;
   }

   /**
   * @return the firstName
   */
   public String getFirstName()
   {
       return firstName;
   }

   /**
   * @param firstName the firstName to set
   */
   public void setFirstName(String firstName)
   {
       this.firstName = firstName;
   }

   /**
   * @return the lastName
   */
   public String getLastName()
   {
       return lastName;
   }

   /**
   * @param lastName the lastName to set
   */
   public void setLastName(String lastName)
   {
       this.lastName = lastName;
   }

   /**
   * @return the idNum
   */
   public int getIdNum()
   {
       return idNum;
   }

   /**
   * @param idNum the idNum to set
   */
   public void setIdNum(int idNum)
   {
       this.idNum = idNum;
   }

   /**
   * @return the city
   */
   public String getCity()
   {
       return city;
   }

   /**
   * @param city the city to set
   */
   public void setCity(String city)
   {
       this.city = city;
   }

}

----------GeneratePeopleFile.java-----------

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Scanner;

public class GeneratePeopleFile
{

   public static void main(String[] args)
   {
       // Starting point of program
       // open a file of Person class and read them into an ArrayList of Persons
       ArrayList<Person> people = new ArrayList<Person>();
       File peopleFile = new File("peopleFile.txt");
       // open a Scanner to read data from File
       Scanner peopleReader = null;
       try
       {
           peopleReader = new Scanner(peopleFile);
       } catch (FileNotFoundException e)
       {
           // TODO Auto-generated catch block
           System.out.println("File not found - terminating program");
           System.exit(0);
           e.printStackTrace();

       }

       // read one person at a time
       while (peopleReader.hasNext())
       {
           // read first name
           String firstName = peopleReader.next();
           String lastName = peopleReader.next();
           String city = peopleReader.next();
           int id = peopleReader.nextInt();
           // create new Person instance and add to ArrayList
           Person temp = new Person(firstName, lastName, id, city);
           people.add(temp);

       }

       // print info to user
       System.out.println("The people from the file are:");
       System.out.println(people);

       // write people to another file
       File secondPeopleFile = new File("people.dat");
       ObjectOutputStream peopleWrite = null;
       try
       {
           peopleWrite = new ObjectOutputStream(new FileOutputStream(secondPeopleFile));

           for (Person temp : people)
           {
               peopleWrite.writeObject(temp);
           }
           peopleWrite.close();
       } catch (IOException e)
       {
           System.out.println("Problems writing to file");

           // TODO Auto-generated catch block
           e.printStackTrace();
       }
   }
}

In: Computer Science

IN PSEUDOCODE and C++ Program 1: Stay on the Screen! Animation in video games is just...

IN PSEUDOCODE and C++

Program 1: Stay on the Screen! Animation in video games is just like animation in movies – it’s drawn image by image (called “frames”). Before the game can draw a frame, it needs to update the position of the objects based on their velocities (among other things). To do that is relatively simple: add the velocity to the position of the object each frame.

For this program, imagine we want to track an object and detect if it goes off the left or right side of the screen (that is, it’s X position is less than 0 and greater than the width of the screen, say, 100). Write a program that asks the user for the starting X and Y position of the object as well as the starting X and Y velocity, then prints out its position each frame until the object moves off of the screen. Design (pseudocode) and implement (source code) for this program.

Sample run 1:

Enter the starting X position: 50

Enter the starting Y position: 50

Enter the starting X velocity: 4.7

Enter the starting Y velocity: 2

X:50    Y:50

X:54.7 Y:52

X:59.4 Y:54

X:64.1 Y:56

X:68.8 Y:58

X:73.5 Y:60

X:78.2 Y:62

X:82.9 Y:64

X:87.6 Y:66

X:92.3 Y:68

X:97    Y:70

X:101.7 Y:72

Sample run 2:

Enter the starting X position: 20

Enter the starting Y position: 45

Enter the starting X velocity: -3.7

Enter the starting Y velocity: 11.2

X:20    Y:45

X:16.3 Y:56.2

X:12.6 Y:67.4

X:8.9   Y:78.6

X:5.2   Y:89.8

X:1.5   Y:101

X:-2.2 Y:112.2

In: Computer Science

JAVA PROGRAMMING ASSIGNMENT - MUST USE ARRAYLIST TO SOLVE. OUTPUT MUST BE EXACT SAME FORMAT AS...

JAVA PROGRAMMING ASSIGNMENT - MUST USE ARRAYLIST TO SOLVE. OUTPUT MUST BE EXACT SAME FORMAT AS SAMPLE OUTPUT.

In this assignment, you will create a program implementing the functionalities of a standard queue in a class called Queue3503. You will test the functionalities of the Queue3503 class from the main() method of the Main class. In a queue, first inserted items are removed first and the last items are removed at the end (imagine a line to buy tickets at a ticket counter).

The Queue3503 class will contain:

a. An int[] data filed named elements to store the int values in the queue.

b. An int data field named size that stores the number of elements in the queue.

c. A no-arg constructor that creates a Queue object with default capacity 0.

d. A constructor that takes an int argument representing the capacity of the queue.

e. A method with signature enqueue(int v) that adds the int element v into the queue.

f. A method with signature dequeue() that removes and returns the first element of the queue.

g. A method with signature empty() that returns true if the queue is empty. h. A method with signature getSize() that returns the size of the queue (return type is hence int)).

The queue class you develop should be tested using the following steps: (In other words, your program named Main will consist of the following)

a. Start your queue with an initial capacity of 8.

b. When the dequeue() method is called, an element from the queue at the beginning of the queue must be removed.

c. The main() method in your Main class should consist of statements to:

i. Create a queue object;

ii. Call enqueue() to insert twenty integers (taken from the user) into the queue.

iii. After the above task is completed, include a for-loop that will print out the contents of the queue.

d. After printing the queue filled with twenty integers, call dequeue() repeatedly to remove the beginning element of the queue.

e. Print the contents of the queue after removing every fifth number.

f. For your reference, the execution of the Main program is shown below. User inputs for populating the Queue is shown in the first line. Next, your program outputs are shown.

Sample Run

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Initial content: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

After removing 5 elements: 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

After removing 5 elements: 11 12 13 14 15 16 17 18 19 20

After removing 5 elements: 16 17 18 19

In: Computer Science