Write a Java program that will ask the user for his/her mark (numerical integer mark) and then convert this numerical mark into letter grades. The following is a guideline to the grading scale used. The numeric range within parenthesis maps to the preceding letter grade. If the user gave you a number greater than 100 or less than 0, you should print a message that the input is invalid. In this code, DO NOT USE && OPERATOR. You should use if-else.
Grades Mapping
A+ (90 to100)
A (80 to 89)
B+ (75 to 79)
B (70 to 74)
C+ (65 to 69)
C (60 to 64)
D+ (55 to 59)
D (50 to 54)
E (40 to 49)
F (0 to 39)
In: Computer Science
Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies.
Ex: If the input is:
0
(or less than 0), the output is:
No change
Ex: If the input is:
45
the output is:
1 Quarter 2 Dimes
c++ please
In: Computer Science
This is a two-part question different than the single-cycle datapath:
a) On the multi-cycle datapath, what are the possible A inputs to the ALU?
b) On the multi-cycle datapath, what are the possible B inputs to the ALU?
In: Computer Science
Java Program
1. Write a program that asks the user: “Please enter a number (0 to exit)”. Your program shall accept integers from the user (positive or negative), however, if the user enters 0 then your program shall terminate immediately. After the loop is terminated, return the total sum of all the previous numbers the user entered.
a. What is considered to be the body of the loop?
b. What is considered the control variable?
c. What is considered to be the test?
d. What is considered to be the update?
e. How can you incorporate the sentinel component into the test?
f. How can you calculate the sum of all previous numbers?
g. Which kind of loop do you think is more convenient to use? And why?
h. Construct the loop based on the information you collected
In: Computer Science
Evaluate the following logical expression. Choose True if the expression evaluates to true; choose False if the expression evaluates to false.
(3 * 5 > 10) || (20 < 15)
True
False
Evaluate the following logical expression. Choose True if the expression evaluates to true; choose False if the expression evaluates to false.
"Medium" < "High"
True
False
Evaluate the following logical expression. Choose True if the expression evaluates to true; choose False if the expression evaluates to false.
(4 + 7 / 2) <= (9 - 15 % 6)
True
False
The two most common control structures are sequence and repetition.
True
False
Evaluate the following logical expression. Choose True if the expression evaluates to true; choose False if the expression evaluates to false.
"High" == "high"
True
False
Evaluate the following logical expression. Choose True if the expression evaluates to true; choose False if the expression evaluates to false.
!(13 - 45 <= 10)
True
False
Evaluate the following logical expression. Choose True if the expression evaluates to true; choose False if the expression evaluates to false.
(3 * 4 == 2 * 6) && (5 * 5 <= 4 * 7)
True
False
Including a space within the relational operators ==, <=, >=, and != creates a syntax error.
True
False
A sequence of statements enclosed in parenthesis () is called a compound statement or block of statements.
True
False
Selection involves executing a statement or block of statements over and over.
True
False
Evaluate the following logical expression. Choose True if the expression evaluates to true; choose False if the expression evaluates to false.
('K' < 'k')
True
False
If a program encounters the following statement, the program will terminate.
return 1;
t
f
Evaluate the following logical expression. Choose True if the expression evaluates to true; choose False if the expression evaluates to false.
(4 * 7) == (74 / 3)
True
False
The following expression always evaluates to true:
if (score = 30)
grade = 'A';
True
False
The IF statement can be used to check for input failure.
True
False
In: Computer Science
DESCRIBE four considerations that best practices dictate, which should be employed when recovering system forensics evidence.
IDENTIFY AND DESCRIBE three reasons why system forensics examiners would want to recover digital evidence from bit-level backups.
In: Computer Science
Python please
A string is one of most powerful data types in programming. A string object is a sequence of characters and because it is a sequence, it is indexable, using index numbers starting with 0. Similar to a list object, a string object allows for the use of negative index with -1 representing the index of the last character in the sequence. Accessing a string object with an invalid index will result in IndexError exception.
In Python a string literal is defined to be a sequence of characters enclosed in single, double or triple quotes.
To define a string object or variable, we use one of the following:
A string object in immutable, meaning, it cannot be changed once it is defined.
The concatenation operator (+) is used to add two or more string objects (strObj1 + strObj2)
The repetition operator (*) is used to repeat the string object (n*strObj or strObj*n, where n is an integer)
The in and not in operators are used to test if one string object is contained in another string object.
Slice a string object using strObj[start:end], start is the index of the starting character and end-1 is the index last character.
The split method creates a list of the split string object.
lstObj = strObj.split(split-character)
space is the default split-character.
The strip method removes the leading and trailing character, the default is space.
strObj.strip(strip-character)
Variations: rstrip, lstrip (left and right strip methods to remove leading and trailing character, respectively)
Other commonly used string methods are
strObj.lower() changes all characters to lowercase
strObj.upper() changes all characters to uppercase
strObj.islower() tests if all characters are lowercase
strObj.isupper() tests if all characters are uppercase
strObj.replace(old, new) replaces old substring with new substring
strObj.find(substring) returns the lowest index of the substring if it is found in strObj
Activity
In: Computer Science
A, B: Design and Implement a C# windows form
application to ask the user for 10 integer numbers, sort them in
ascending order and display the sorted list. Use bubble sort
technique to sort the array elements and do not use any built-in
sort method to sort the array elements.
[02]
C: Test and evaluate your program by inputting variety
of values.
In: Computer Science
Using R
Question 3. kNN Classification
3.1 Read in iris dataset using “data(iris)”. Describe the features
in the data using summary
3.2 Randomize the iris data set, mix it up and normalize it
3.3 split data into training & testing (70/30 split)
3.4 Train model in data and use crosstable function to evaluate the
results
3.5 Rerun your code for K=10 and 100. Compare results and
explain
In: Computer Science
In: Computer Science
Write a program ( Java) to solve the 8-puzzle problem (and its natural generalizations) using the A* search algorithm. The problem. The 8-puzzle problem is played on a 3-by-3 grid with 8 square blocks labeled 1 through 8 and a blank square. Your goal is to rearrange the blocks so that they are in order. You are permitted to slide blocks horizontally or vertically into the blank square. The following shows a sequence of legal moves from an initial board position (left) to the goal position (right). 13 13 123 123 123 4 2 5 => 4 2 5 => 4 5 => 4 5 => 4 5 6 786 786 786 786 78 initial goal Best-first search. We now describe an algorithmic solution to the problem that illustrates a general artificial intelligence methodology known as the A* search algorithm. We define a state of the game to be the board position, the number of moves made to reach the board position, and the previous state. First, insert the initial state (the initial board, 0 moves, and a null previous state) into a priority queue. Then, delete from the priority queue the state with the minimum priority, and insert onto the priority queue all neighboring states (those that can be reached in one move). Repeat this procedure until the state dequeued is the goal state. The success of this approach hinges on the choice of priority function for a state. Hamming priority function. The number of blocks in the wrong position, plus the number of moves made so far to get to the state. Intuitively, a state with a small number of blocks in the wrong position is close to the goal state, and we prefer a state that have been reached using a small number of moves. For example, the Hamming and Manhattan priorities of the initial state below are 5 and 10, respectively. 813 123 12345678 12345678 4 2 4 5 6 ---------------------- ---------------------- 765 78 11001101 12002203 initial goal Hamming = 5 + 0 Manhattan = 10 + 0 We make a key observation: to solve the puzzle from a given state on the priority queue, the total number of moves we need to make (including those already made) is at least its priority, using either the Hamming or Manhattan priority function. (For Hamming priority, this is true because each block that is out of place must move at least once to reach its goal position. For Manhattan priority, this is true because each block must move its Manhattan distance from its goal position. Note that we do not count the blank tile when computing the Hamming or Manhattan priorities.) Consequently, as soon as we dequeue a state, we have not only discovered a sequence of moves from the initial board to the board associated with the state, but one that makes the fewest number of moves. A critical optimization. After implementing best-first search, you will notice one annoying feature: states corresponding to the same board position are enqueued on the priority queue many times. To prevent unnecessary exploration of useless states, when considering the neighbors of a state, don't enqueue the neighbor if its board position is the same as the previous state. 813 813 813 424242 765 765 765 previous state disallow Your task. Write a program Java that reads the initial board from standard input and prints to standard output a sequence of board positions that solves the puzzle in the fewest number of moves. Also print out the total number of moves and the total number of states ever enqueued. The input will consist of the board dimension N followed by the N-by-N initial board position. The input format uses 0 to represent the blank square. Important note: implement the Hamming priority function. Sample input: 3 013 425 786 Sample output: 13 425 786 13 425 786 123 45 786 123 45 786 123 456 78 Number of states enqueued = 10 Minimum number of moves = 4 Note that your program should work for arbitrary N-by-N boards (for any N greater than 1), even if it is too slow to solve some of them in a reasonable amount of time.
In: Computer Science
What is web caching? (4) b) Describe how Web caching can reduce the delay in receiving a requested object. (4) c) Are there benefits for web caching other than reducing the delay? (2
In: Computer Science
In the game Rock Paper Scissors, two players simultaneously choose one of three options: rock, paper, or scissors. If both players choose the same option, then the result is a tie. However, if they choose differently, the winner is determined as follows:
• Rock beats scissors, because a rock can break a pair of
scissors.
• Scissors beats paper, because scissors can cut paper.
• Paper beats rock, because a piece of paper can cover a rock.
Create a game in which the computer randomly (hint: Math.random()) chooses rock, paper, or scissors. Let the user enter "rock", "paper" or "scissor". Then, determine the winner.
Save the application as RockPaperScissors.java.
In: Computer Science
In: Computer Science
Consider the following database schema:
LIKE(person, sport),
PRACTICE(person, sport),
where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that person likes.
Express the following queries in relational algebra
In: Computer Science