1/Your team was asked to program a self-driving car that reaches its destination with minimum travel time.
Write an algorithm for this car to choose from two possible road trips. You will calculate the travel time of each trip based on the car current speed and the distance to the target destination. Assume that both distances and car speed are given.
2/
Write a complete Java program that do the following:
Note:Your program output should look as shown below.
My Name: Ameera Asiri
My student ID: 123456789
My Course Name: Computer Programming
My Course Code: CS140
My Course CRN: 12345
AIYSHA ASIRI
Note: Include the screenshot of the program output as a part of your answer.
3/
Write a tester program to test the mobile class defined below.
Create the class named with your id (for example: Id12345678) with the main method.
Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.
public class Mobile {
private int id;
private String brand;
public Mobile() {
id = 0;
brand = "";
}
public Mobile(int n, String name) {
id = n;
brand = name;
}
public void setBrand(String w) {
brand = w;
}
public void setId(int w) {
id = w;
}
Public int getId() {
return id;
}
public String getBrand() {
return brand;
}
}
4/
Write a method named raiseSalary that accepts two integers as an argument and return its sum multiplied by 15%. Write a tester program to test the method. The class name should be your ID (for example: Id12345678).
Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.
In: Computer Science
#C.
Write a program that accepts any number of homework scores ranging in value from 0 through 10. Prompt the user for a new score if they enter a value outside of the specified range. Prompt the user for a new value if they enter an alphabetic character. Store the values in an array. Calculate the average excluding the lowest and highest scores. Display the average as well as the highest and lowest scores that were discarded.
In: Computer Science
Please provide ALL documentation stated at the bottom (in bold) for each circuit
Description: Build and test the following circuits using gate-level modeling in Verilog HDL.
1. 3-input majority function.
2. Conditional inverter (see the table below: x - control input, y - data input). Do NOT use XOR gates for the implementation.
| x | Output |
| 0 | y |
| 1 | y' |
3. Two-input multiplexer (see the table below: x,y - data inputs, z - control input).
| z | Output |
| 0 | x |
| 1 | y |
4. 1-bit half adder.
5. 1-bit full adder by cascading two half adders.
6. 1-bit full adder directly (as in fig. 4.7 in the text).
7. 4-bit adder/subtractor with overflow detection by cascading four 1-bit full adders (see fig. 4.13 in the text). Use multiple bit variables (vectors) for the inputs and output (see 4-bit-adder.vl)
Requirements:
Documentation:
***************Write a project report containing for each circuit:***************************
In: Computer Science
1/Your team was asked to program a self-driving car that reaches its destination with minimum travel time.
Write an algorithm for this car to choose from two possible road trips. You will calculate the travel time of each trip based on the car current speed and the distance to the target destination. Assume that both distances and car speed are given.
2/
Write a complete Java program that do the following:
Note:Your program output should look as shown below.
My Name: Ameera Asiri
My student ID: 123456789
My Course Name: Computer Programming
My Course Code: CS140
My Course CRN: 12345
AIYSHA ASIRI
Note: Include the screenshot of the program output as a part of your answer.
3/
Write a tester program to test the mobile class defined below.
Create the class named with your id (for example: Id12345678) with the main method.
Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.
public class Mobile {
private int id;
private String brand;
public Mobile() {
id = 0;
brand = "";
}
public Mobile(int n, String name) {
id = n;
brand = name;
}
public void setBrand(String w) {
brand = w;
}
public void setId(int w) {
id = w;
}
Public int getId() {
return id;
}
public String getBrand() {
return brand;
}
}
4/
Write a method named raiseSalary that accepts two integers as an argument and return its sum multiplied by 15%. Write a tester program to test the method. The class name should be your ID (for example: Id12345678).
Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.
In: Computer Science
Please convert This java Code to C# (.cs) Please make sure the code can run and show the output Thank you! Let me know if you need more information. Intructions
For this assignment you will be creating two classes, an interface, and a driver program:
Class Calculator will implement the interface CalcOps
o As such it will implement hexToDec() - a method to convert
from
Hexadecimal to Decimal.
Class HexCalc will inherit from Calculator.
Interface CalcOps will have abstract methods for add( ), subtract( ),
multiply( ) and divide( ).
Both classes will implement the CalcOps interface.
o Class Calculator’s add, subtract, multiply and divide will take in 2 integers and return an integer. If you prefer it can take in 2 strings, and return a string.
o Class HexCalc’s add, subtract, multiply and divide will take in 2 strings (hexadecimal numbers) and return a string (hexadecimal number).
This Calculator class will work with whole numbers (int) and hexadecimal (String) values. The hexToDec ( ) method is a helper method included in interface CalcOps, that requires the Calculator class to implement the method which converts hexadecimal numbers to decimal. (Hint: Use language specific utility methods to convert hexadecimal to decimal.)
SOURCE CODE
TestCalculator.java
---------------------------------------------------------------------
import java.util.*;
public class TestCalculator {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Would you like to do calculations with " +
"decimal or hexadecimal numbers (1 for Decimal, 2 for Hexadecimal)?");
int choice = sc.nextInt();
while(true) {
int operation = menu();
if (operation == 0) {
System.out.println("You chose to Exit> THANK YOU !!! HAVE A GREAT DAY!!! ");
System.exit(0);
}
Calculator parent = new Calculator();
if (choice == 1) {
System.out.println("Please enter the first number");
int first = sc.nextInt();
System.out.println("Please enter the second number");
int second = sc.nextInt();
switch (operation) {
case 1:
System.out.println(parent.add(first, second));
break;
case 2:
System.out.println(parent.subtract(first, second));
break;
case 3:
System.out.println(parent.multiply(first, second));
break;
case 4:
System.out.println(parent.divide(first, second));
break;
}
}
if (choice == 2) {
System.out.println("Please enter the first hexadecimal number");
String f = sc.next();
System.out.println("Please enter the second hexadecimal number");
String s = sc.next();
HexCalc child = new HexCalc();
// convert from String to int
int first = parent.hexToDec(f);
int second = parent.hexToDec(s);
switch (operation) {
case 1:
System.out.println(child.decToHex(parent.add(first, second)));
break;
case 2:
System.out.println(child.decToHex(parent.subtract(first, second)));
break;
case 3:
System.out.println(child.decToHex(parent.multiply(first, second)));
break;
case 4:
System.out.println(child.decToHex(parent.divide(first, second)));
break;
}
}
}
}
public static int menu() {
System.out.println("---MENU---");
System.out.println("0 - Exit");
System.out.println("1 - Addition");
System.out.println("2 - Subtraction");
System.out.println("3 - Multiplication");
System.out.println("4 - Division");
System.out.print("Please Choose an Option: ");
return sc.nextInt();
}
}
-------------------------------------------------------------------------------------------
Calcops interface
----------------
public interface Calcops {
// basic arithmetic operations
public int hexToDec (String hexToDecimal) ;
public int add(int a1, int a2);
public int subtract(int s1, int s2);
public int multiply(int m1, int m2);
public int divide(int d1, int d2);
}
-----------------------------------------------------------------------------------------------------
Calculator.java
-------------------------------------------
public class Calculator implements CalcOps{
public int hexToDec(String hexToDecimal) {
int dec = Integer.parseInt(hexToDecimal,16);
return dec;
}
public int add(int x, int y) {
return x+y;
}
public int subtract(int x, int y) {
return x-y;
}
public int multiply(int x, int y) {
return x*y;
}
public int divide(int x, int y) {
return x/y;
}
}
-------------------------------------------------------------------------------------------------------
HexCalc.java
----------------
public class HexCalc extends Calculator implements CalcOps{
public String decToHex(int Dec) {
String hex = Integer.toHexString(Dec);
return hex;
}
}
================================================================================================
OUTPUT
===================================================
In: Computer Science
(a) Create a class Webcam which stores the information of a webcam. It includes the brand, the model number (String) and the price (double, in dollars). Write a constructor of the class to so that the information mentioned is initialized when a Webcam object is created. Also write the getter methods for those variables. Finally add a method toString() to return the webcam information in the following string form. "brand: Logitech, model number: B525, price: 450.0" Copy the content of the class as the answers to this part.
(b) Create a class ComputerShop which stores the webcam information in a map webcamMap, whose key is the concatenation of the brand and model number, separated by ": " (a colon and a space). The value is a Webcam object. Write a method addWebcam(Webcam oneWebcam) which adds oneWebcam to webcamMap. Copy the content of the class, which any include import statement(s) required, as the answers to this part.
(c) Create a class TestComputerShop with a main() method which creates a ComputerShop object aShop and add the first webcam with brand "Logitech", model number "B525" and price 450.0. Add the second webcam with brand "Microsoft", model number "HD-3000" and price 235.0. Copy the content of the class as the answers to this part.
(d) Write a method showWebcam() of ComputerShop which loops through the keys of webcamMap using the enhanced for-loop and directly prints each webcam object stored using System.out.println(). (Loop through the values is simpler but using the keys is required in this part.) This should show suitable information since the method toString() has been written in (a). Add a statement in TestComputerShop to display all the webcam information of aShop. Copy the content of the method, line(s) added and execution output as the answers to this part.
(e) Write a method modelNumberSet() of ComputerShop which returns model numbers of the webcams in a set. You should loop through the values of webcamMap using the enhanced for-loop and collect the model numbers. Add a statement in TestComputerShop to display the set using System.out.println(). Copy the content of the method, line(s) added and new execution output as the answers to this part.
(f) Write a method priceList() of ComputerShop which returns the prices of the webcams in a list. You should loop through the values of webcamMap using the enhanced for-loop and collect the prices of the webcams. Add a statement in TestComputerShop to display the list using System.out.println(). Copy the content of the method, line(s) added and new execution output as the answers to this part.
In: Computer Science
Write a program that plays an addition game with the user (imagine the user is a 5th grade student).
First ask the user how many addition problems they want to attempt.
Next, generate two random integers in the range between 10 and 50 inclusive. You must use the Math.random( ) method call. Prompt the user to enter the sum of these two integers. The program then reports "Correct" or "Incorrect" depending upon the user's "answer". If the answer was incorrect, show the user the the correct sum.
Display a running total of how many correct out of how many total problems ( ex: 2 correct out of 5, 3 correct out of 5, etc) after each problem is answered.
Continue this until the user has attempted the total number of problems desired.
java
In: Computer Science
A checksum is a value that is computed based upon some information. It is functional in the sense that given the same information, the exact same value will be computed. Checksums are often used when information is being transmitted over a network. This lets the receiving end know if the information was transmitted accurately.
All published books have a unique 10 and 13 digit ISBN number. This stands for International Standard Book Number. Your textbook in this class has an ISBN-10 number. The first 9 digits (which may include leading zeros) are the information part of the ISBN-10 number. The 10th digit is a checksum which is calculated from the other 9 digits using the following formula where d1 is the first digit beginning on the left, d2 is the second digit, etc.:
( (1* d1) + (2 * d2) + (3 * d3) + (4 * d4) + (5 * d5) + (6 * d6) + (7 * d7) + (8 * d8) + (9 * d9) ) % 11
Because the large sum then uses modulus 11 arithmetic, the possible values for the checksum are the numbers 0 through 10. According to the ISBN-10 convention, the checksum can only be a single character (digit) so if the checksum is 10 the last character is denoted as X (Roman numeral for 10) .
Write a program that loops, prompting the user to enter the first 9 digits into an input dialog box. You must parse the input value as a single integer. Compute the checksum digit and output the complete 10 digit ISBN number using a Confirm Dialog asking if the user wants to enter another 9 digit number. If the user selects the YES button, then loop. If NO is selected, the program will end.
An example of this program in action (without dialog boxes) is:
Enter the first 9 digits of an ISBN number: 013601267 <enter>
The ISBN-10 number is: 0136012671
Do you want to enter another? <yes>
Enter the first 9 digits of an ISBN number: 013031997 <enter>
The ISBN-10 number is: 013031997X
Do you want to enter another? <no>
Extracting the Digits from the Integer
The algorithm to compute the checksum is relatively simple, so the interesting part of this program is figuring out how to extract each of the 9 digits from the integer. Hint: Section 3.13 (9th Edition) Case Study: Lottery shows you how to extract the digits from a 2-digit number.
Remember, I am forcing you to turn the String from the dialog box into an integer. I will not accept a solution that doesn't do this. When the ISBN number has leading zeros, it makes the problem more complex because you must go from a String to an int and back to a String again.
In: Computer Science
There are several typical cube computation methods such as Multi-Way, BUC, and Star-cubing. Briefly describe each one of these methods outlining the key points.
Please write, not a screenshot
In: Computer Science
A RISC processor that uses the five-stage instruction fetch and execution design is driven by a 1-GHz clock. Instruction statistics in a large program are as follows:
Branch 20%
Load 30%
Store 10%
Computational instructions 40%
Please answer the following questions.
1-Assume 80% of the memory access operations are in the cache, and 20% are in the main memory. A cache miss has a 3-cycle penalty. What is the instruction throughput for non-pipelined execution?
2- Assume there are an instruction cache and a data cache. For both caches, a cache miss stalls the pipeline for 3 cycles. Assume the cache hit rate for the instruction cache is 85%. 80% of the Load instructions load data from the data cache, while 20% of them load data from the main memory. 40% of the Store instructions store data into the data cache, while 60% of them store data into the main memory. What is the instruction throughput for pipelined execution?
3-Assume all memory accesses are cache hit. 20% of the Load instructions are followed by a dependent computational instruction, and 30% of the computational instructions are also followed by a dependent computational instruction. 20% of the branch instructions are unconditional, while 80% are conditional. 40% of the conditional branches are taken, 60% are not taken. The penalty for taking the branch is one cycle. If data forwarding is allowed, what is the instruction throughput for pipelined execution?
In: Computer Science
In each of these exercises, consider the relation, CKs, and FDs. Determine if the relation is in BCNF, and if not in BCNF give a non-loss decomposition into BCNF relations. The last 5 questions are abstract and give no context for the relation nor attributes.
1. Consider a relation Player which has information about
players for some sports league. Player has attributes id, first,
last, gender. id is the only CK and the FDs are:
idfirst
idlast
idgender
Player-sample data
| ID | First | Last | gender |
| 1 | Jim | Jones | Male |
| 2 | Betty | Smith | Female |
| 3 | Jim | Smit | Male |
| 4 | Lee | Mann | Male |
| 5 | Samantha | McDonald | Female |
2.Consider a relation Employee which has information about
employees in some company. The employee has attributes id, first,
last, sin (social insurance number) where id and sin are the only
CKs, and the FDs are:
idfirst
idlast
sinfirst
sinlast
idsin
sinid
Employee – sample data
| ID | First | Last | SIN |
| 1 | Jim | Jones | 111222333 |
| 2 | Betty | Betty | 333333333 |
| 3 | Jim | Smith | 456789012 |
| 4 | Lee | Mann | 123456789 |
| 5 | Samantha | McDonald | 987654321 |
In: Computer Science
a/ write 4 numbers from your choice
b/ Write a java code to create a linked list containing the 4 numbers
In: Computer Science
/*
* bitCount - returns count of number of 1's in word
* Examples: bitCount(5) = 2, bitCount(7) = 3
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 40
* Rating: 4
*/
int bitCount(int x) {
return 2;
}
Can you please complete this code in C language without the use of any loops such as if, do, while, for, switch, etc., macros, other operations, such as &&, ||, -, or ?: .
In: Computer Science
In: Computer Science
using python/IDLE
(1) Prompt the user to enter a string of their choosing. Store
the text in a string. Output the string. (1 pt)
Ex:
Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
(2) Implement a print_menu() function, which has a string as a
parameter, outputs a menu of user options for analyzing/editing the
string, and returns the user's entered menu option and the sample
text string (which can be edited inside the print_menu() function).
Each option is represented by a single character.
If an invalid character is entered, continue to prompt for a
valid choice. Hint: Implement the Quit menu option before
implementing other options. Call print_menu() in the main
section of your code. Continue to call print_menu() until the user
enters q to Quit. (3 pts)
Ex:
MENU c - Number of non-whitespace characters w - Number of words f - Fix capitalization r - Replace punctuation s - Shorten spaces q - Quit Choose an option:
(3) Implement the get_num_of_non_WS_characters() function.
get_num_of_non_WS_characters() has a string parameter and returns
the number of characters in the string, excluding all whitespace.
Call get_num_of_non_WS_characters() in the print_menu() function.
(4 pts)
Ex:
Number of non-whitespace characters: 181
(4) Implement the get_num_of_words() function. get_num_of_words()
has a string parameter and returns the number of words in the
string. Hint: Words end when a space is reached except for the
last word in a sentence. Call get_num_of_words() in the
print_menu() function. (3 pts)
Ex:
Number of words: 35
(5) Implement the fix_capitalization() function.
fix_capitalization() has a string parameter and returns an updated
string, where lowercase letters at the beginning of sentences are
replaced with uppercase letters. fix_capitalization() also returns
the number of letters that have been capitalized. Call
fix_capitalization() in the print_menu() function, and then output
the the edited string followed by the number of letters
capitalized. Hint 1: Look up and use Python functions
.islower() and .upper() to complete this task. Hint 2: Create an
empty string and use string concatenation to make edits to the
string. (3 pts)
Ex:
Number of letters capitalized: 3 Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!
(6) Implement the replace_punctuation() function.
replace_punctuation() has a string parameter and two keyword
argument parameters exclamation_count and
semicolon_count. replace_punctuation() updates the
string by replacing each exclamation point (!) character with a
period (.) and each semicolon (;) character with a comma (,).
replace_punctuation() also counts the number of times each
character is replaced and outputs those counts. Lastly,
replace_punctuation() returns the updated string. Call
replace_punctuation() in the print_menu() function, and then output
the edited string. (3 pts)
Ex:
Punctuation replaced exclamation_count: 1 semicolon_count: 2 Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here, our hopes and our journeys continue.
(7) Implement the shorten_space() function. shorten_space() has a
string parameter and updates the string by replacing all sequences
of 2 or more spaces with a single space. shorten_space() returns
the string. Call shorten_space() in the print_menu() function, and
then output the edited string. Hint: Look up and use Python
function .isspace(). (3 pt)
Ex:
Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
In: Computer Science