Questions
In Java, you can iterate an ArrayList in different ways. Write the following methods to print...

In Java, you can iterate an ArrayList in different ways. Write the following methods to print Integers in an ArrayList iterating in different ways:

1. // Using basic while / for loop
void printArrayListBasicLoop(ArrayList<Integer> al);

2. // Using enhanced for loop (:)
void printArrayListEnhancedLoop(ArrayList<Integer> al);

3. // Using basic for loop with iterator
void printArrayListForLoopListIterator(ArrayList<Integer> al);

4. // Using basic while loop with iterator

void printArrayListWhileLoopListIterator(ArrayList<Integer>

al);

In: Computer Science

Translate the following procedure to RISC-V assembly long long int myfun(long long int a, long long...

Translate the following procedure to RISC-V assembly

long long int myfun(long long int a, long long int b)
{
  return fun(fun(a-b), a+b);
}

Assume that function fun exists and accepts a single long long int argument and returns a long long int argument. Make use of the tail call optimization if possible, and use the least number of stack operations (reading and writing to the stack). You do not need to write comments or a main program. Submit a regular file called myfun.asm. You do not need to run it on the simulator.

In: Computer Science

Please write code in C, thank you. Write a program that reads a list of integers,...

Please write code in C, thank you.

Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain less than 20 integers.

Ex: If the input is:

5 2 4 6 8 10

the output is:

all even

Ex: If the input is:

5 1 3 5 7 9

the output is:

all odd

Ex: If the input is:

5 1 2 3 4 5

the output is:

not even or odd

Your program must define and call the following two functions. IsArrayEven returns true if all integers in the array are even and false otherwise. IsArrayOdd returns true if all integers in the array are odd and false otherwise.
bool IsArrayEven(int inputVals[], int numVals)
bool IsArrayOdd(int inputVals[], int numVals)

In: Computer Science

Write a Java program named CircleZapper that displays a circle with a radius of 10 pixels,...

Write a Java program named CircleZapper that displays a circle with a radius of 10 pixels, filled with a random color at a random location on the screen. When you click the circle, it disappears and a new random color circle is displayed at another random location (see display below). After twenty circles are clicked, display the time spent in the pane. To detect whether a point is inside the circle, use the contains method defined in the Node class. You can capture the initial starting time with a statement like:

startTime = System.currentTimeMillis()

In: Computer Science

I'm trying to get my code to loop back to let the user input multiple patients....

I'm trying to get my code to loop back to let the user input multiple patients.

import java.util.Scanner;

public class XYZ {

   public static void main(String[] args) {   
       String response;

       do{
           //import scanner for input
           Scanner input = new Scanner(System.in);   
           //prompt user input for last name
           System.out.print("Enter last name ");
           //output for last name
           String s1 = input.nextLine();
           //prompt user input for first name
           System.out.print("Enter first name ");
           //output for first name
           String s2 = input.nextLine();
           //prompt user for street address
           System.out.print("Enter street address ");
           //output for street address
           String address = input.nextLine();
           //prompt user for city
           System.out.print("Enter city ");
           //output for city
           String city = input.nextLine();
           //prompt user for state
           System.out.print("Enter state ");
           //output for state
           String state = input.nextLine();
           //prompt user for zipcode
           System.out.print("Enter zip code ");
           //output for zip code
           String zip = input.nextLine();
           //prompt user for owed amount
           System.out.print("Enter amount owed ");
           //output for amount owed
           String amount = input.nextLine();
           //prompt user for payment amount
           System.out.print("Enter payment amount ");
           //output for payment amount
           String payment = input.nextLine();
           //prompt user for payment date
           System.out.print("Enter payment date ");
           //output for payment date
           String date = input.nextLine();

          


       //final print out output title
       System.out.printf("%80s\n", "XYZ Community Hospital");
       //final print out spacing
       System.out.printf(String.format("%150s\n", "").replace(' ', '='));
       //final print out titles and spacing
       System.out.printf("%10s%30s%80s\n", "Name", "Address", "Payment Information");
       //final print out titles and spacing
       System.out.printf("%-8s %-12s %-30s %-15s %-5s %-10s %-15s %-15s %-15s \n", "Last", "First", "Address Line 1", "City", "State", "Zip", "Amount Owed",

               "Payment Amt.", "Payment Date");

       System.out.printf(String.format("%150s\n", "").replace(' ', '='));
       //final output print out
       System.out.printf("%-8s %-12s %-30s %-15s %-5s %-10s %-15s %-15s %-15s \n", s1, s2, address, city, state, zip, amount, payment, date);

       //ask user for next entry
       System.out.println("Would you like to make another entry?[Y/N]");
       response = input.nextLine();
       input.close();
   }
   while (response==("Y")); }

      
  
   }

In: Computer Science

Develop a program that calculates the final score and the average score for a student from...

Develop a program that calculates the final score and the average score for a student from his/her (1)class participation, (2) test, (3) assignment, (4) exam, and (5) practice scores.

The user should enter the name of the student and scores ranging from 0 to 100 for each grading item.

The final score is the sum of all grading items.

The average score is the average of all grading items.

Here is a sample output of the program:

Enter the Student's name: John Smith
Enter Class Participation Score ranging from 0 to 100: 89
Enter Test Score ranging from 0 to 100: 87
Enter Assignment Score ranging from 0 to 100: 67
Enter Exam Score ranging from 0 to 100: 99
Enter Practice Score ranging from 0 to 100: 80
John Smith: Final Score: 422 Average Score: 84.4

In: Computer Science

(python) Write a function that involves two arguments, named changeTheCase(myFile, case),thattakes, as arguments, the name of...

(python) Write a function that involves two arguments, named changeTheCase(myFile, case),thattakes, as arguments, the name of a file, myFile, and the case, which will either be"upper"or"lower".If case is equal to "upper" the function will open the file, convert all characters on each line to upper case, write each line to a new file, named "upperCase.txt", and return the string "Converted file to upper case."If case is equal to "lower" the function will open the file, convert all characters on each line to lowercase, write each line to a new file, named "lowerCase.txt", and return the string"Converted file to lower case." If case is any other value, the function returns the string "Invalid parameter."

For example:

>>>changeTheCase("hello.txt","upper")

should open the file named hello.txt, convert each character in each line to upper case, write each converted line to a new file named upperCase.txt, close both files,

and return the string "Converted file to upper case." As another example:

>>>changeTheCase("hello.txt", "lower")

should open the file named hello.txt, convert each character in each line to lower case, write each converted line to a new file named lowerCase.txt, close both files,

and return the string "Converted file to lower case." As a final example:

>>>changeTheCase("hello.txt","yibbie")

should return the string"Invalid parameter."

In: Computer Science

C++ C++ We are prompting input from the users. Users input "I like the book "The...

C++

C++

We are prompting input from the users.

Users input "I like the book "The little prince" very much"

I want to separate this sentence by the order "I" "like" "the" "book" "the little prince" "very" "much". (Keep the quotation mark of little prince, because it is the way the user entered)

and adding this to a arraylist in c++  

In: Computer Science

I know that there are several different answers that has already been posted for this. I...

I know that there are several different answers that has already been posted for this. I have tried all of the options but wanted to see if I can get a correct one that actually works.

Assume that a gallon of paint covers about 350 square feet of wall space. Create an application with a main() method that prompts the user for the length, width, and height of a rectangular room. Pass these three values to a method that does the following:

  • Calculates the wall area for a room
  • Passes the calculated wall area to another method that calculates and returns the number of gallons of paint needed
  • Displays the number of gallons needed
  • Computes the price based on a paint price of $32 per gallon, assuming that the painter can buy any fraction of a gallon of paint at the same price as a whole gallon
  • Returns the price to the main() method

The main() method displays the final price. For example:

You will need 2.0 gallons
The price to paint the room is $64.0

Grading

Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade.

Once you are happy with your results, click the Submit button to record your score.

  • PaintCalculator.java

14

1

import java.util.Scanner;

2

public class PaintCalculator {

3

    public static void main (String args[]) {

4

        // Write your code here

5

    }

6

7

    public static double computeArea(double length, double width, double height) {

8

        // Write your code here

9

    }

10

    public static double computeGallons(double area) {

11

        // Write your code here

12

    }

13

}

14

​Please, please please help!  I've been working on this problem for a week now.

In: Computer Science

''' Problem 1: Formin' Functions Define and complete the functions described below. The functions are called...

'''
Problem 1: Formin' Functions

Define and complete the functions described below.

The functions are called in the code at the very bottom. So you should be
able simply to run the script to test that your functions work as expected.
'''

'''
* function name: say_hi
* parameters: none
* returns: N/A
* operation:
Uhh, well, just say "hi" when called. And by "say" I mean "print".
* expected output:

>>> say_hi()
hi

'''

'''
* function name: personal_hi
* parameters: name (string)
* returns: N/A
* operation:
Similar to say_hi, but you should include the name argument in the greeting.
* expected output:

>>> personal_hi("Samantha")
Hi, Samantha

'''

'''
* function name: introduce
* parameters: name1 (string)
name2 (string)
* returns: N/A
* operation:
Here you are simply including the two names in a basic introduction.
* expected output:

>>> introduce("Samantha","Jerome")
Samantha: Hi, my name is Samantha!
Jerome: Hey, Samantha. Nice to meet you. My name is Jerome.

'''


# FUNCTIONS ARE CALLED BELOW HERE...NO NEED TO TOUCH ANYTHING
# UNLESS YOU WANT TO COMMENT SOMETHING OUT TO TEST THINGS
# ALONG THE WAY...

say_hi()
personal_hi("Larry")
personal_hi("Naomi")
introduce("Larry","Naomi")

In: Computer Science

you are required to use only the functional features of Scheme; functions with an exclamation point...

you are required to use only the functional features of Scheme; functions with an exclamation point in their names (e.g., set!) and input/output mechanisms other than load and the regular read-eval-print loop are not allowed. (You may find imperative features useful for debugging. That’s ok, but get them out of your code before you hand anything in.)

Write a function explode that, given a list of tuples, (n x), creates a new list by inserting x into the list n times in place of (n x) (in other words, the inserted items should come in the same order as the original tuples when you create the new list). You can assume that n will always be at least 0.

> (explode ‘((2 "Hello")))

("Hello" "Hello")

> (explode ‘((2 "Hello") (3 "world")))

("Hello" "Hello" "world" "world" "world")

using the programming language scheme

In: Computer Science

CIT 1615 Lab Assignment 187.63.200.0 /24 Objective: You have been hired to design a subnetting scheme...

CIT 1615 Lab Assignment

187.63.200.0 /24

Objective: You have been hired to design a subnetting scheme using VLSM to meet the requirements of the network shown. This assignment will guide you through each step. Fill in each blank and then complete the table that is at the end of this document. Subnet

Address Requirement

Faculty

25 hosts

Admin

12 hosts

Student

96 hosts

Guest

3 hosts

Serial to Gateway Router

2 hosts

Step 1: We will determine all of the network addresses based on host requirements shown in the table above. We always want to start with the subnet that has the largest host requirement. What is the name of this subnet?

(a) Subnet Name:_________________________   (b) Number of Required Hosts:_________

The network address of this subnet will be the original network address, but it will have a different subnet mask (prefix length). So we need to determine this. What is the best fitting prefix length and subnet mask for the number of hosts required of this subnet?

(c)Subnet Address (copy original network address):________________________

(d) Prefix Length:________________    (e) Subnet Mask:_______________________

Choosing a prefix length will break the address space into equal blocks of a certain size – the size depending on the prefix length. Given the prefix length you just chose, what size blocks is the address space broken into?

(f) Blocks of size _________

Step 2: We need to identify the next largest subnet.

(a) Subnet Name:_________________________   (b) Number of Required Hosts:_________

The prefix length you chose in Step 1 will determine the network address for this subnet. Add the block size from the previous step (1.f) to the network address in the previous step (1.c) to determine this subnet address.

(c) Subnet Address:______________________

This subnet may have a different prefix length than the previous subnet. What is the best fitting prefix length and subnet mask for the number of host required of this subnet?

(d) Prefix Length:________________    (e) Subnet Mask:_______________________

What size blocks did this prefix length break the address space into?

(f) Blocks of size _________

Step 3: We need to identify the next largest subnet.

(a) Subnet Name:_________________________   (b) Number of Required Hosts:_________

The prefix length you chose in Step 2 will determine the network address for this subnet. Add the block size from the previous step (2.f) to the network address in the previous step (2.c) to determine this subnet address.

(c) Subnet Address:______________________

This subnet may have a different prefix length than the previous subnet. What is the best fitting prefix length and subnet mask for the number of host required of this subnet?

(d) Prefix Length:________________    (e) Subnet Mask:_______________________

What size blocks did this prefix length break the address space into?

(f) Blocks of size _________

Step 4: We need to identify the next largest subnet.

(a) Subnet Name:_________________________   (b) Number of Required Hosts:_________

The prefix length you chose in Step 3 will determine the network address for this subnet. Add the block size from the previous step (3.f) to the network address in the previous step (3.c) to determine this subnet address.

(c) Subnet Address:______________________

This subnet may have a different prefix length than the previous subnet. What is the best fitting prefix length and subnet mask for the number of host required of this subnet?

(d) Prefix Length:________________    (e) Subnet Mask:_______________________

What size blocks did this prefix length break the address space into?

(f) Blocks of size _________ 

Step 5: Finally we need a network address for the serial connection. These connections will always require two addresses, which means a /30 prefix length.

Subnet Name: Serial Connection         Number of Required Hosts: 2

The prefix length you chose in Step 4 will determine the network address for this subnet. Add the block size from the previous step (4.f) to the network address in the previous step (4.c) to determine this subnet address.

(a) Subnet Address:______________________

Prefix Length:/30    (b) Subnet Mask:_______________________

What size blocks did this prefix length break the address space into?

(c) Blocks of size _________

Step 6: Now that you have determined all of the network addresses and prefix lengths, complete the table below. Remember that the broadcast address will be the last possible address in a subnet. Or it will be one less than the next network address. The first usable host address is one more than the network address, and the last usable host address is one less than the broadcast address.

Network Address

Subnet Mask

Broadcast Address

Usable Host Range

First Subnet

Second Subnet

Third Subnet

Fourth Subnet

Serial Connection

In: Computer Science

''' Problem 2: Functions that give answers Define and complete the functions described below. The functions...

'''
Problem 2: Functions that give answers

Define and complete the functions described below.

The functions are called in the code at the very bottom. So you should be
able simply to run the script to test that your functions work as expected.
'''

'''
* function name: get_name
* parameters: none
* returns: string
* operation:
Here, I just want you to return YOUR name. The expected output below assumes
that your name is Paul. Of course, replace this with the real article.
* expected output:

# JUST RETURNS THE NAME...TO VIEW IT YOU CAN PRINT IT AS BELOW
>>> print(get_name())
Paul

'''

'''
* function name: get_full_name
* parameters: fname (string)
lname (string)
first_last (boolean)
* returns: string
* operation:
Return (again, NOT print) the full name based on the first and last names
passed in as arguments. The first_last argument will be True if you should
return the name as <fname lname> and False if you shoudl return the name
as <lname, fname>.
* expected output:

# AGAIN JUST RETURNS THE NAME...TO VIEW IT YOU CAN PRINT IT AS BELOW
>>> print(get_full_name("Paul","York",True))
Paul York
>>> print(get_full_name("Paul","York",False))
York, Paul

'''

'''
* function name: get_circle_area
* parameters: radius (float)
* returns: float
* operation:
Return the area of a circle with the given radius. Use 3.14 as Pi. And Google if for
some reason you've forgotten how to get the area of a circle.
* expected output:

# YET AGAIN JUST RETURNS THE VALUE
>>> print(get_circle_area(5.0))
78.5
>>> print(get_circle_area(2.5))
19.625

'''

# FUNCTIONS ARE CALLED BELOW HERE...NO NEED TO TOUCH ANYTHING
# UNLESS YOU WANT TO COMMENT SOMETHING OUT TO TEST THINGS
# ALONG THE WAY...

print(get_name())
print(type(get_name())) # >>> <class 'str'>
print(get_full_name("Darth","Vader",True))
print(get_full_name("Luke","Skywalker",False))
print(type(get_full_name("Han","Solo",False))) # >>> <class 'str'>
print(get_circle_area(5.0)) # 78.5
print(get_circle_area(2.5)) # 19.625
print(get_circle_area(12.25)) # 471.19625

In: Computer Science

File IO Java question • Ask the user to specify the file name to open for...

File IO Java question

• Ask the user to specify the file name to open for reading

• Get the number of data M (M<= N) he wants to read from file

• Read M numbers from the file and store them in an array

• Compute the average and display the numbers and average.

In: Computer Science

Java assignment Get a file name fname for output • Get number of data (numbers) (N)...

Java assignment

Get a file name fname for output

• Get number of data (numbers) (N) you want to process from the user

• Get N numbers from the users through keyboard and store them in an array

• Write the numbers into the file fname

In: Computer Science