A dice has 6 face values: one, two, three, four, five, and six. If you roll a dice, you will see one of them with equal opportunity. Write a java program which rolls a dice 6000 times. The ideal case is that each face value will appear 1000 times. However, your program should give slightly different numbers.
In: Computer Science
Write a program in java which calculates the total price of an item you purchased which includes sales tax. Create a Scanner object to read information from keyboard, Display prompts and get input, perform the calculation and display the Result of the program.
In: Computer Science
What is the result of the command ?
$ who | grep $USER
$ grep \$HOME economics1
$ echo u*>> economics1
$ echo ‘u*’ >> economics1
$ . economicsA
$ set noclobber
$ set -o
$ chmod +x economics2
$ spell < economics1
economic is file name
linux command
In: Computer Science
1. Explain the following:
a) Types Real Time Systems.
b) Design metrics for Real Time Embedded Systems.
2. Explain the main differences between ASIP, FPGA, PLD and ASIC.
3. Define the processor technology and compare between single purpose processor, general purpose proces- sor and application specific processor.
In: Computer Science
4. Identify the key differences between hard real-time, soft real-time and firm real-time systems. Give at least one example of real time tasks corresponding to these three categories. Identify the timing constraints in your tasks and justify why the tasks should be categorized into the categories you have indicated.
5. What is an Embedded and Real Time System?
6. Enumerate some Embedded Computers that are exists from origin of the Embedded Systems.
In: Computer Science
Code in C#
Part 1
Build a Series
class that has the following attributes and behaviors:
Attributes
1.) A name -- this can be any string value (i.e. “Firefly”)
2.) A number of episodes -- this can be any non-negative integer value
3.) An episode length -- this can be a double value, in hours, representing the length of an episode (i.e. 0.5 for a half-hour episode, or 0.37 for a 23 minute episode)
4.) A forKids attribute that holds a boolean value representing whether the show is suitable for kids. A boolean value true means the show is kid-friendly.
Behaviors
1.)Create a method named GetViewingHours that returns the total amount of hours of content for this series. This can be calculated by multiplying the number of episodes by the episode length.
2.) Create a method named PrintDetails that prints to the console the name, number of episodes, and the length of each episode.
Part 2
: In Main(), create an application that allows for the following:
1.) Output a line of text that shows the name of your Streaming Service.
2.) Prompt the user to enter a name of a series, the number of episodes in the series, the length of each episode, and whether or not the series is kid-friendly. For simplicity, assume each episode of the series has the same length.
3.) Keep prompting the user to enter more series’ information until the total viewing hours available is greater than 1000 hours. (This means your channel has ~ 2 years of content if consumed at 1.5 hours a day).
4.) After all series have been entered, print out the details of all kid-friendly series.
5.) After all series have been entered, print the name of the series with the most episodes.
6.)After all series have been entered, print the average length of each series
In: Computer Science
Task 2
We are producing two types of products, product A and product B. Product A is defective if the weight is greater than 10 lbs. Product B is defective if the weight is greater than 15 lbs. For a given product, we know its product_type and its weight. Design a program to screen out defective products. Starting the program with variable definition:
product_type = 'xxx'
weight = xxx
Hint: You need to figure out the product type first, and then check if the product is defective based on the weight. You may use a nested if statement like the following:
if product is A:
if product weight > 10:
the product is defective
else:
if product weight >15:
the product is defective
But you need to translate the English into Python codes.
As a challenge, you may also try a one-step if statement. such as :
if some condition is met:
the product is defective
else:
the product is normal
And the key is the bolded “some condition”.
In: Computer Science
Write the following Java code into Pseudocode
import java.util.*;
public class Main
{ // Searching module
public static void score_search(int s,int score[])
{ // Initialise flag as 0
int flag=0;
// Looping till the end of the array
for(int j=0;j<10;j++)
{ // If the element is found in the array
if(s==score[j])
{ // Update flag to 1
flag=1;
}
}
// In case flag is 1 element is found
if(flag==1)
{
System.out.println("golf score found");
}
// // In case flag is 0 element is not found
else
{
System.out.println("golf score not found");
}
// Modification module
public static int[] modify(int score[],int t)
{ // Initialise new score array
int newscore[]=new int[11];
// Copying the scores to the new array
for(int k=0;k<10;k++)
{
newscore[k]=score[k];
}
// storing the new score at the last position
newscore[10]=t;
// return the new score array
return newscore;
}
// main function
public static void main(String[] args) {
// Declaring the variables
int swap,i,a,b,search,temp;
// Instantiate object of Scanner class
Scanner sc=new Scanner(System.in);
// Declaring the golf score array
int score[]=new int[10];
System.out.print("Enter the golf scores:");
// Asking user to enter the golf scores
for(i=0;i<10;i++)
{
score[i]=sc.nextInt();
}
// Sorting the golf scores in ascending order
// Looping til the end of the array
for(a=0;a<10;a++)
{ // Looping from second element till the end
for(b=a+1;b<10;b++)
{ // In case first score is greater then second
score
// Swap the golf scores
if(score[b]<score[a])
{
swap=score[a];
score[a]=score[b];
score[b]=swap;
}
}
}
System.out.print("Sorted golf
scores:");
// Printing the sorted golf
scores
for(i=0;i<10;i++)
{
System.out.print(score[i]+"
");
}
System.out.println("");
System.out.println("Enter the score
to be searched:");
// Asking user to enter the golf
score to be searched
search=sc.nextInt();
// Calling the Searching
module
score_search(search,score);
System.out.println("Enter the new
score:");
// Asking user to enter the golf
score to be added
temp=sc.nextInt();
// Printing and calling the
Modification module
System.out.println("Modified golf
score:"+Arrays.toString(modify(score,temp)));
}
}
In: Computer Science
What is the CIDR for Each ?? Please Explain.
Demilitarized Zone (DMZ) Network Segment (10.252.1.x)
Internal Servers & Storage Network Segment (10.252.5.x)
Marketing Network Segment (10.252.7.x)
Financial Advisors Network Segment (10.252.2.x)
Human Resources (HR) Network Segment (10.252.9.x)
Information Technology (IT) Network Segment (10.252.3.x)
Shipping Network Segment (10.252.8.x)
Receiving Network Segment (10.252.6.x)
Operations (OPS) Network Segment (10.252.4.x)
In: Computer Science
Please write the answer on a computer not on a paper
I'm a little confused as to what exactly I'm researching and writing about. If someone could break it down and give me a few minor examples so I can structure the essay around it I would really appreciate it:
(Intel 80x86, ARM, MIPS R4000 )Write a two page report on the similarities and differences are of these architectures. Include in your report what you find interesting about the architectures you researched
In: Computer Science
7. What are the applications of an Embedded and Real Time Systems.
8. Analyze in detail about the challenges in Embedded and Real-Time systems design.
9. What are the parameters to be considered while designing an Embedded System Process?
10. Why microprocessor/microcontroller is used in Embedded system.
In: Computer Science
In: Computer Science
Imagine you have a rotary combination lock with many dials. Each dial has the digits 0 - 9. At any point in time, one digit from each dial is visible.
Each dial can be rotated up or down. For some dial, if a 4 is currently visible then rotating the dial up would make 5 visible; rotating the dial down would make 3 visible. When 0 is the visible digit then rotating down would make 9 visible. Similarly, when 9 is visible then rotating up would make 0 visible.
We have devised a robotic finger to manipulate such combination systems. The robotic finger takes as input a String that indicates the operations to be performed. An L moves the finger one dial to the left, an R moves the finger one dial to the right, and a + rotates the dial that the finger is at up and a - rotates the dial that the finger is at down.
The robotic finger always starts at the leftmost dial.
Task 1: Basic Operations
Valid Sequence
Given a String that consists of (only) the characters L, R, + and -, determine if this String represents a valid sequence of operations.
A valid sequence of operations would not move the finger to the left of the leftmost dial or to the right of the rightmost dial.
public boolean validOperation(String ops, int numDials) {
Rotations
Given a sequence of operations in String form, as well as an initial arrangement of the dials, determine the digits that will be visible after the operations have been performed.
public int[] rotate(int[] initialState, String ops) {
Task 2: Finding Rotation Sequences
Given an initial state of the dials and a final state, return a String that represents a sequence of operations of shortest length that transforms the initial state to the final state.
public String getRotationSequence(int[] initialState, int[] newState) {
TEST CASE
@Test
public void testValidOp1() {
RoboticFinger rf = new RoboticFinger();
assertTrue(rf.validOperation("R++L++-RRR", 4));
}
@Test
public void testValidOp2() {
RoboticFinger rf = new RoboticFinger();
assertTrue(!rf.validOperation("R++L++-RRR", 3));
}
@Test
public void testValidOp3() {
RoboticFinger rf = new RoboticFinger();
assertTrue(!rf.validOperation("L-+R++RR", 10));
}
@Test
public void testValidOp4() {
RoboticFinger rf = new RoboticFinger();
assertTrue(!rf.validOperation("RRR+-R+R+LL", 4));
}
@Test
public void testValidOp5() {
RoboticFinger rf = new RoboticFinger();
assertTrue(rf.validOperation("RRR+-R+R+LL", 6));
}
@Test
public void testRotate1() {
RoboticFinger rf = new RoboticFinger();
int[] initialState = {1, 2, 4, 4, 5};
String ops = "R++R-";
int[] expectedState = {1, 4, 3, 4, 5};
assertArrayEquals(expectedState, rf.rotate(initialState, ops));
}
@Test
public void testRotate2() {
RoboticFinger rf = new RoboticFinger();
int[] initialState = {1, 2, 4, 4, 5};
String ops = "R++R-R-L++";
int[] expectedState = {1, 4, 5, 3, 5};
assertArrayEquals(expectedState, rf.rotate(initialState, ops));
}
@Test
public void testRotate3() {
RoboticFinger rf = new RoboticFinger();
int[] initialState = {7, 0, 2, 9, 1, 5, 6};
String ops = "R-R++R+++R+RR--";
int[] expectedState = {7, 9, 4, 2, 2, 5, 4};
assertArrayEquals(expectedState, rf.rotate(initialState, ops));
}
@Test
public void testGetRotationSequence1() {
RoboticFinger rf = new RoboticFinger();
int[] initialState = {1, 2, 4, 4, 4, 7};
int[] finalState = {2, 7, 3, 4, 8, 9};
int expectedLength = "+R+++++R-RR++++R++".length();
String ops = rf.getRotationSequence(initialState, finalState);
assertArrayEquals(finalState, rf.rotate(initialState, ops));
assertEquals(expectedLength, ops.length());
}
@Test
public void testGetRotationSequence2() {
RoboticFinger rf = new RoboticFinger();
int[] initialState = {9, 9, 9, 9, 9, 9, 1};
int[] finalState = {2, 7, 3, 4, 8, 9, 2};
int expectedLength = 22;
String ops = rf.getRotationSequence(initialState, finalState);
assertArrayEquals(finalState, rf.rotate(initialState, ops));
assertEquals(expectedLength, ops.length());
}
@Test
public void testGetRotationSequence3() {
RoboticFinger rf = new RoboticFinger();
int[] initialState = {5};
int[] finalState = {7};
int expectedLength = 2;
String ops = rf.getRotationSequence(initialState, finalState);
assertArrayEquals(finalState, rf.rotate(initialState, ops));
assertEquals(expectedLength, ops.length());
}In: Computer Science
C++ programming
Create an application for generating lottery tickets of random numbers. Each lottery ticket has a fixed count of numbers to be played with each number selected being within a given range. For example, when the range of numbers is 1 through 100, and 5 numbers are to be played, the lottery ticket will be composed of 5 unique values between 1 and 100. The values are selected at random.
The main function is responsible for obtaining the upper range of the numbers and the count of numbers to be played from the end user. The count of numbers must be less than the upper range. The main function will call the generateLotto function to generate the lottery ticket and then call the displayTicket function to display the resulting lottery ticket. Any number of lottery tickets may be generated.
The generateLotto function should accept two parameters. The first should be the upper range for the numbers while the second parameter represents a count of the numbers to be played. For example, lotto(51, 6) will select 6 numbers at random between 1 and 51 (inclusive.) The function should return a vector of unique integer values in sorted order.
The displayTicket function accepts a vector of integers and displays the vector.
Hints: Although the standard library defines a rand() function for generating random numbers, the function may produce duplicate numbers and hence, is not suitable for this application. To ensure that unique values are generated, create a vector that contains all possible values (1 through the given upper range) and then shuffle these values using the random_shuffle() function. This will result in a vector of numbers between 1 and the upper range in random order. From this vector, select the required number of values from the beginning of the vector, adding these values to the result vector. Lastly, use the sort() function to sort the result vector.
The random_shuffle() and sort() functions require two parameters that specify the beginning and ending elements on which to operate. To specify the beginning and ending of the vector, the begin() and end() methods of the vector class can be used. For example, when the vector allNumbers contains all the values between 1 and 51, the values within the vector can be rearranged (shuffled) using: random_shuffle(allNumbers.begin(),allNumbers.end());
In: Computer Science
Write a C++ program that reads numbers from the user until the user enters a Sentinel. Use a Sentinel of -999. Ignore all negative numbers from the user input (other than the sentinel).
Do the following:
1. Output the sum of all even numbers
2. Output the sum of all odd numbers
3. Output the count of all even numbers
4. Output the count of all odd numbers
You must use alternation ('if' statements), loops and simple calculations to do this. You must not use any arrays or vectors for this program.
In: Computer Science