Questions
Write a Java Program.A parking garage charges a $3.00 minimum fee to park for up to...

Write a Java Program.A parking garage charges a $3.00 minimum fee to park for up to three hours. The garage charges an additional $0.75 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $12.00 per day. Write an application that calculates and displays the parking charges for all customers who parked in the garage yesterday. You should enter the hours parked for each customer. The program should display the charge for the current customer and should calculate and display the grand total of yesterday’s receipts. Use a sentinel controlled loop.

In: Computer Science

How does page fault in OS be handled/resolved?

How does page fault in OS be handled/resolved?

In: Computer Science

Create two groups named VB (GID=5001) and Norfolk (GID=5002). • Create three different accounts with password...

Create two groups named VB (GID=5001) and Norfolk (GID=5002).
• Create three different accounts with password under each group
• Display the accounts information of each user, including UID, GID, and password hash.

In linux

In: Computer Science

4. Write a program that reads all numbers from a file and determines the highest and...

4. Write a program that reads all numbers from a file and determines the highest and lowest numbers. You must NOT use arrays to solve this problem! Write functions where appropriate.

Programming language should be C

In: Computer Science

Write 2 detailed samples of scary text-based computer games. The location of your game could be...

Write 2 detailed samples of scary text-based computer games. The location of your game could be a place that truly exists (possibly include research). Exclude graphic content. Remember to give choices to the player during the game.

The 2 text based games must be invented by you and list scene by scene the options given to the player.

Brief example of what the samples should look like:

There is an old, dark castle in front of you, will you go in? (options for the player: 1 yes; 2 no)

[...story details...]

Inside the room there is a dark figure standing in front of you (options for the player: 1 use phone;  2 get a gun; 3 leave the room)

[...]

you do not need to use a programming language, just writing 2 scary short stories as if they were games using your own words, and listing options for the player. each slide of the story leads to a next slide according to the decisions made by the player

Please, new answer

In: Computer Science

Create a Web application that display an animal classification. For the classification uses the given csv...

Create a Web application that display an animal classification. For the classification uses the given csv file: test1.csv
(open up the csv file in any no-code insertion text editor like: notepad, wordpad (windows); or vi, emacs, nano, pico (Macs)
– just plain text editor NOT word processor like Word, Pages, etc). The csv file contains information on
the types, traits, and examples of animal classification.
Give the user the following options (it can be in radio buttons) to see the information:
1. The examples of animals in alphabetical order for each type
2. Any oviparous animal, and
3. Which and how many are cold-blooded?
Note. Implement the application with HTML/Javascript and JSP. The application should be treated as a client-server application.

In: Computer Science

public class SumMinMaxArgs { private int[] array; // You will need to write the following: //...

public class SumMinMaxArgs {
    private int[] array;
    // You will need to write the following:
    //
    // 1. A constructor that takes a reference to an array,
    //    and initializes an instance variable with this
    //    array reference
    //
    // 2. An instance method named sum, which will calculate
    //    the sum of the elements in the array.  If the array
    //    is empty (contains no elements), then this will
    //    will return 0.  You will need a loop for this.
    //
    // 3. An instance method named min, which will return
    //    whichever element in the array is smallest.
    //    You can assume that min will only be called if the
    //    array is non-empty (contains at least one element).
    //    You will need a loop for this.  You may use the
    //    Math.min method here (see link below for more)
    //    https://www.tutorialspoint.com/java/lang/math_min_int.htm
    //
    // 4. An instance method named max, which will return
    //    whichever element in the array is largest.
    //    You can assume that max will only be called if the
    //    array is non-empty (contains at least one element).
    //    You will need a loop for this.  You may use the
    //    Math.max method here (see link below for more)
    //    https://www.tutorialspoint.com/java/lang/math_min_int.htm
    //
    // TODO - write your code below


    // DO NOT MODIFY parseStrings!
    public static int[] parseStrings(String[] strings) {
        int[] retval = new int[strings.length];
        for (int x = 0; x < strings.length; x++) {
            retval[x] = Integer.parseInt(strings[x]);
        }
        return retval;
    }

    // DO NOT MODIFY main!
    public static void main(String[] args) {
        int[] argsAsInts = parseStrings(args);
        SumMinMaxArgs obj = new SumMinMaxArgs(argsAsInts);
        System.out.println("Sum: " + obj.sum());
        System.out.println("Min: " + obj.min());
        System.out.println("Max: " + obj.max());
    }
}
Sum: 15
Min: 1
Max: 5
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;

public class SumMinMaxArgsTest {
    @Test
    public void testParseStringsLength0() {
        assertArrayEquals(SumMinMaxArgs.parseStrings(new String[0]),
                          new int[0]);
    }

    @Test
    public void testParseStringsLength1() {
        assertArrayEquals(SumMinMaxArgs.parseStrings(new String[]{"1"}),
                          new int[]{1});
    }

    @Test
    public void testParseStringsLength2() {
        assertArrayEquals(SumMinMaxArgs.parseStrings(new String[]{"1", "42"}),
                          new int[]{1, 42});
    }

    @Test
    public void testSumArrayLength0() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[0]);
        assertEquals(0, obj.sum());
    }

    @Test
    public void testSumArrayLength1() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1});
        assertEquals(1, obj.sum());
    }

    @Test
    public void testSumArrayLength2() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2});
        assertEquals(3, obj.sum());
    }

    @Test
    public void testSumArrayLength3() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2, 3});
        assertEquals(6, obj.sum());
    }

    @Test
    public void testSumArrayLength4() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2, 3, 4});
        assertEquals(10, obj.sum());
    }
    
    @Test
    public void testMinArrayLength1() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength2MinFirst() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength2MinSecond() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 1});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength3MinFirst() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2, 3});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength3MinSecond() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 1, 3});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength3MinThird() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{3, 2, 1});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMaxArrayLength1() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1});
        assertEquals(1, obj.max());
    }

    @Test
    public void testMaxArrayLength2MaxFirst() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 1});
        assertEquals(2, obj.max());
    }

    @Test
    public void testMaxArrayLength2MaxSecond() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2});
        assertEquals(2, obj.max());
    }

    @Test
    public void testMaxArrayLength3MaxFirst() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{3, 2, 1});
        assertEquals(3, obj.max());
    }

    @Test
    public void testMinArrayLength3MaxSecond() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 3, 1});
        assertEquals(3, obj.max());
    }

    @Test
    public void testMaxArrayLength3MaxThird() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 1, 3});
        assertEquals(3, obj.max());
    }
} // SumMinMaxArgsTest

In: Computer Science

You have to get a new driver's license and you show up at the office at...

You have to get a new driver's license and you show up at the office at the same time as 4 other people. The office says that they will see everyone in alphabetical order and it takes 20 minutes for them to process each new license. All of the agents are available now, and they can each see one customer at a time. How long will it take for you to walk out of the office with your new license? Task Given everyone's name that showed up at the same time, determine how long it will take to get your new license. Input Format Your input will be a string of your name, then an integer of the number of available agents, and lastly a string of the other four names separated by spaces. Output Format You will output an integer of the number of minutes that it will take to get your license. Implement the code in java

In: Computer Science

Java Implement a class MyInteger that contains: • An int data field/instance variable named value that...

Java

Implement a class MyInteger that contains:

• An int data field/instance variable named value that stores the int value represented by this object.

• A constructor that creates a MyInteger object for a default int value. What default value did you choose? What other values did you consider? Why did you make this choice?

• A constructor that creates a MyInteger object for a specified int value.

• A getter method, valueOf(), that returns value.

• A setter method, setValue(int), that replaces the current value with the specified one and returns the original value.

• The method equals(int) that return true if the value in this object is equal to the specified value. This method will not override Object’s equals() method.

• The method toString() that returns a text (String) version of value. toString() must include thousands grouping separators when value is greater than 999. This method will override Object’s toString() method. You will need to use String.format() to get the desired result.

• The static methods isZero(int), isEven(int) and isOdd(int) that return true if the specified value is zero, even or odd, respectively.

• The instance methods isZero(), isEven() and isOdd() that return true if the value in this object is zero, even or odd, respectively. Do not duplicate the code in the static methods – use them to do the work in the instance methods.

• The methods increment() and decrement() that increase or decrease value by 1, respectively. These methods should both modify value and return its new value.

• The instance methods add(int), subtract(int), multiplyBy(int), divideBy(int), and remainder(int), corresponding to the five arithmetic operators (+, -, *, /, %). These methods should both modify value and return its new value.

Continue by adding the following:

• The instance method equals(Object) that return true if the value in this object is equal to the value of the specified instance (the parameter – an instance of MyInteger). This method will override Object’s equals() method. You must check the parameter to make sure it’s not null and that it’s a MyInteger before you can cast it to a MyInteger and interrogate its value.

• The instance methods add(MyInteger), subtract(MyInteger), multiplyBy(MyInteger), divideBy(MyInteger), and remainder(MyInteger), corresponding to the five arithmetic operators (+, -, *, /, %). These methods should both modify value in this instance and return its new value. The specified instance (parameter) is unchanged.

• The methods isPrime() and isPrime(MyInteger) that return true if the value in this object or the specified instance (parameter), respectively, is a prime number. isPrime() is an instance method and isPrime(MyInteger) is a static method.

• The static methods parseInt(char[]) that converts an array of numeric characters to an int value and parseInt(String) that converts a String of numeric characters to an int value. You must do the conversions by hand (hint: subtract '0' from each digit character to get its numeric value).

• Javadoc comments for all methods. Make sure you generate the documentation for all public elements.

Create a MyIntegerStudentTests to test all methods. Your tests should include positive numbers, negative numbers, and zero as arguments and as the results of the operations. Make sure you test the static and instance methods.

Your program should not do any input/prompting. The output is mostly up to you, but it should inform the user of the operations under test and the expected and actual results.

In: Computer Science

What is the minimum number of bits needed to encode the days of the month in...

What is the minimum number of bits needed to encode the days of the
month in a Canadian calendar.

1.

5

2.

3

3.

6

4.

4

In: Computer Science

Problem 1. Write two computer programs to simulate a Unicode stream cipher that consists of both...

Problem

1. Write two computer programs to simulate a Unicode stream cipher that consists of both
encryption and decryption algorithms. The encryption program accepts inputs from an
existing text file, called “letter.txt.” The encryption program produces an output ciphertext
file, called “secret” The decryption program takes “secret” as input and decrypts it into a
plaintext, called “message.txt.”


- The random “seed” must be known, but be kept secure, by the pseudorandom number
generators in both encryption and decryption programs.

Note from me: Use Java.

In: Computer Science

I'm trying to do some pratice problems in the book and here is one of them....

I'm trying to do some pratice problems in the book and here is one of them.

THIS IS FOR JAVA.

Write a method cleanCorruptData that accepts an ArrayList of integers and removes any adjacent pair of integers in the list if the left element of the pair is smaller than the right element of the pair. Every pair's left element is an even-numbered index in the list, and every pair's right element is an odd index in the list. For example, suppose a variable called list stores the following element values: [3, 7, 5, 5, 8, 5, 6, 3, 4, 7]

We can think of this list as a sequence of pairs: (3, 7), (5, 5), (8, 5), (6, 3), (4, 7). The pairs (3, 7) and (4, 7) are "bad" because the left element is smaller than the right one, so these pairs should be cleaned (or removed). So the call of cleanCorruptData(list); would change the list to store the following element values: [5, 5, 8, 5, 6, 3]

If the list has an odd length, the last element is not part of a pair and is also considered "corrupt;" it should therefore be cleaned by your method. If an empty list is passed in, the list should still be empty at the end of the call. You may assume that the list passed is not null. You may not use any other arrays, lists, or other data structures to help you solve this problem.

THIS IS FOR JAVA.

In: Computer Science

Basically, the code already functions properly. Could you just write in method header comments explaining what...

Basically, the code already functions properly. Could you just write in method header comments explaining what the method does and what the parameters are? Some of them are already done. Additionally could you change the variables and method names to make them more descriptive of what they're actually holding? Thank you!


import java.util.Scanner;

/**
* This class contains the entire program to print out a yearly calendar.
*
* @author
* @author TODO add your name here when you contribute
*/
public class Calendar {

public static void tc(char c3, int c4) {
for (int pie = 0; pie < c4; pie++) {
System.out.print(c3);
}
}

public static boolean yr(int yr2) {
/* TODO this really should be in a method header JavaDoc comment rather than hidden in the method.
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible
by 100, but these centurial years are leap years if they are exactly divisible by 400. For example,
the years 1700, 1800, and 1900 are not leap years, but the years 1600 and 2000 are.
https://en.wikipedia.org/wiki/Leap_year
*/
boolean yri = false;
if (yr2 % 4 == 0) {
if (yr2 % 100 == 0) {
if (yr2 % 400 == 0) {
yri = true;
} else {
yri = false;
}
} else {
yri = true;
}

} else {
yri = false;
}
return yri;
}

/**
* This returns the number of days in the specified month of year.
*
* @param month The month to return the number of days.
* @param year The year is used for determining whether it is a leap year.
* @return The number of days in the specified month of the year.
*/
public static int getDaysInMonth(int month, int year) {
int daysInMonth = 0;
switch (month) {
//31 days
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
daysInMonth = 31;
break;

//30 days
case 4:
case 6:
case 9:
case 11:
daysInMonth = 30;
break;

case 2: //28 or 29 days
if ( yr(year)) {
daysInMonth = 29;
} else {
daysInMonth = 28;
}
break;
}
return daysInMonth;
}

/**
* Returns the name of the month, given the number of the month.
*
* @param month The month where 1 is January and 12 is December.
* @return The name of the month.
*/
public static String getMonthName(int month) {
String monthStr;
switch (month) {
case 1:
monthStr = "January";
break;
case 2:
monthStr = "February";
break;
case 3:
monthStr = "March";
break;
case 4:
monthStr = "April";
break;
case 5:
monthStr = "May";
break;
case 6:
monthStr = "June";
break;
case 7:
monthStr = "July";
break;
case 8:
monthStr = "August";
break;
case 9:
monthStr = "September";
break;
case 10:
monthStr = "October";
break;
case 11:
monthStr = "November";
break;
case 12:
monthStr = "December";
break;
default:
monthStr = "UNKNOWN";
break;
}
return monthStr;
}

public static void p(String n, int h) {
final int TOTAL_WIDTH = 28;
final char MONTH_HEADER_LINE_CHAR = '-';

System.out.println();
String it = n + " " + h;
int spacesBefore = (TOTAL_WIDTH - it.length()) / 2;
tc(' ', spacesBefore);
System.out.println(it);
tc(MONTH_HEADER_LINE_CHAR, TOTAL_WIDTH);
System.out.println();
System.out.println("Sun Mon Tue Wed Thu Fri Sat");
}

public static void d2(int da, int md) {
final char CHAR_BETWEEN_DAYS = ' ';
final int DAYS_IN_A_WEEK = 7;
final int LOWEST_SINGLE_DIGIT_DAY = 1;
final int HIGHEST_SINGLE_DIGIT_DAY = 9;

tc( CHAR_BETWEEN_DAYS, da * 4);
for ( int zzzz = 1; zzzz <= md; zzzz++) {
if ( zzzz >= LOWEST_SINGLE_DIGIT_DAY && zzzz <= HIGHEST_SINGLE_DIGIT_DAY) {
tc(CHAR_BETWEEN_DAYS, 2);
} else {
tc( CHAR_BETWEEN_DAYS, 1);
}
System.out.print( zzzz);
tc( CHAR_BETWEEN_DAYS, 1);
da++;
if ( da % DAYS_IN_A_WEEK == 0) {
System.out.println();
}
}
System.out.println();
}

/**
* This prompts for the year and the day of the week of January 1st and then
* prints out a calendar for the entire year.
*
* @param args unused
*/
public static void main(String[] args) {
final char FIRST_MONTH = 1;
final char LAST_MONTH = 12;
final int DAYS_IN_A_WEEK = 7;

Scanner input = new Scanner(System.in);
System.out.print("Enter year:");
int year = input.nextInt();
System.out.print("Enter day of week of Jan 1 (0-Sunday, 1-Monday, etc):");
int startDay = input.nextInt();

for ( int month = FIRST_MONTH; month <= LAST_MONTH; ++month) {
String monthName = getMonthName( month);
p( monthName, year);

int daysInMonth = getDaysInMonth(month, year);
d2(startDay, daysInMonth);

startDay = (startDay + daysInMonth) % DAYS_IN_A_WEEK;
}
}
}

In: Computer Science

Code in Java Create a stack class to store integers and implement following methods: 1) void...

Code in Java

Create a stack class to store integers and implement following methods:

1) void push(int num): This method will push an integer to the top of the stack.

2) int pop(): This method will return the value stored in the top of the stack. If the stack is empty this method will return -1.

3) void display(): This method will display all numbers in the stack from top to bottom (First item displayed will be the top value).

4) Boolean isEmpty(): This method will check the stack and if it is empty, this will return true, otherwise false.

In: Computer Science

Assume i = 4, j = 9, k = 5 and m = -3. What does...

Assume i = 4, j = 9, k = 5 and m = -3. What does each of the following statements print?

a) printf("%d", i == 4);

b) printf("%d", j!= 3);

c) printf("%d", i >= 5 && j < 2);

d) printf("%d", !m || k > m);

e) printf("%d", !k && m);

f) printf("%d", k - m < j || 5 - j >= k);

g) printf("%d", j + m <= i && !0);

h) printf("%d", !(j + m)); i) printf("%d", !(k < m)); j) printf("%d", !(j < k));

In: Computer Science