Complete the following method to return the median of three integers. Remember, you need to use the names of the parameters as given in the method header. This is a return method, so you need to include return statement(s) NOT System.out.println.
JAVA PROGRAM
Exampe:
| Method call | Value returned |
| medof | 5 |
| medof | 5 |
| medof | -2 |
| medof | 0 |
Method header:
public static int medof(int n1,int n2, int n3)
In: Computer Science
Program 1: Stay on the Screen! Animation in video games is just like animation in movies – it’s drawn image by image (called “frames”). Before the game can draw a frame, it needs to update the position of the objects based on their velocities (among other things). To do that is relatively simple: add the velocity to the position of the object each frame.
For this program, imagine we want to track an object and detect if it goes off the left or right side of the screen (that is, it’s X position is less than 0 and greater than the width of the screen, say, 100). Write a program that asks the user for the starting X and Y position of the object as well as the starting X and Y velocity, then prints out its position each frame until the object moves off of the screen. Design (pseudocode) and implement (source code) for this program.
//////// WRITE IN PSEUDOCODE ////////
Sample run 1:
Enter the starting X position: 50
Enter the starting Y position: 50
Enter the starting X velocity: 4.7
Enter the starting Y velocity: 2
X:50 Y:50
X:54.7 Y:52
X:59.4 Y:54
X:64.1 Y:56
X:68.8 Y:58
X:73.5 Y:60
X:78.2 Y:62
X:82.9 Y:64
X:87.6 Y:66
X:92.3 Y:68
X:97 Y:70
X:101.7 Y:72
Sample run 2:
Enter the starting X position: 20
Enter the starting Y position: 45
Enter the starting X velocity: -3.7
Enter the starting Y velocity: 11.2
X:20 Y:45
X:16.3 Y:56.2
X:12.6 Y:67.4
X:8.9 Y:78.6
X:5.2 Y:89.8
X:1.5 Y:101
X:-2.2 Y:112.2
////////WRITE IN PSEUDOCODE//////
In: Computer Science
In a certain building at a top secret research lab , some yttrium-90 has leaked into the computer analysts' coffee room. The leak would currently expose personnel to 150 millirems of radiation a day. The half-life of the substance is about three days; that is, the radiation level is only half of what it was three days ago. The analysts want to know how long it will be before the radiation is down to a safe level of 0.466 millirem a day. They would like a chart that displays the radiation level for every three days with the message Unsafe or Safe after every line. The chart should stop just before the radiation level is one-tenth of the safe level, because the more cautious analysts will require a safety factor of 10. The program should also print the first day that the room can be entered.
In: Computer Science
Code in C++
Assign negativeCntr with the number of negative values in the
linked list.
#include <iostream>
#include <cstdlib>
using namespace std;
class IntNode {
public:
IntNode(int dataInit = 0, IntNode* nextLoc = nullptr);
void InsertAfter(IntNode* nodePtr);
IntNode* GetNext();
int GetDataVal();
private:
int dataVal;
IntNode* nextNodePtr;
};
// Constructor
IntNode::IntNode(int dataInit, IntNode* nextLoc) {
this->dataVal = dataInit;
this->nextNodePtr = nextLoc;
}
/* Insert node after this node.
* Before: this -- next
* After: this -- node -- next
*/
void IntNode::InsertAfter(IntNode* nodeLoc) {
IntNode* tmpNext = nullptr;
tmpNext = this->nextNodePtr; // Remember next
this->nextNodePtr = nodeLoc; // this -- node -- ?
nodeLoc->nextNodePtr = tmpNext; // this -- node -- next
}
// Grab location pointed by nextNodePtr
IntNode* IntNode::GetNext() {
return this->nextNodePtr;
}
int IntNode::GetDataVal() {
return this->dataVal;
}
int main() {
IntNode* headObj = nullptr; // Create intNode objects
IntNode* currObj = nullptr;
IntNode* lastObj = nullptr;
int i;
int negativeCntr;
negativeCntr = 0;
headObj = new IntNode(-1); // Front of nodes list
lastObj = headObj;
for (i = 0; i < 10; ++i) { // Append 10 rand nums
currObj = new IntNode((rand() % 21) - 10);
lastObj->InsertAfter(currObj); // Append curr
lastObj = currObj; // Curr is the new last item
}
currObj = headObj; // Print the list
while (currObj != nullptr) {
cout << currObj->GetDataVal() << ", ";
currObj = currObj->GetNext();
}
cout << endl;
currObj = headObj; // Count number of negative numbers
while (currObj != nullptr) {
/* Your solution goes here */
currObj = currObj->GetNext();
}
cout << "Number of negatives: " << negativeCntr
<< endl;
return 0;
}
In: Computer Science
convert 0xC2000000 into IEEE-754 single precision decimal format.
In: Computer Science
I'm having trouble understanding this concept. I already completed the first part now I need to convert the Second Part into a Control Structure. Please help answering the Problem. The first part will be below.
(Second Part)
Continuing with Control Structures
Control Structures are called such because they control the execution flow during the running of a program. There are 3 basic control structures: Sequence, Selection and Loop. This week let's work with the structures we already know - Sequence and Selection - but now let's add the loop structure to our logical programming toolbox.
Remember (from CIS 103) that the defining factor of a structured programming logic is that each control structure has exactly 1 entry point and 1 exit point. How do the 'break' and 'continue' statements, used in loop structures, that we learn about in Chapter 4, affect structured programming logic? (2 points, write answer in text box)
Chapter 4 (section 4.1 through 4.9)
Submit SalaryCalcLoop.java
Update SalaryCalc.java (Salary Calculator) from last week to now continue to take input for every employee in a company, and display their information until a sentinel value is entered (pg. 219), that exits the loop and ends the program.
(First Part Already completed)
import java.util.Scanner;
public class SalaryCalc {
double Rpay = 0, Opay = 0;
void calPay(double hours, double rate) {
if (hours <= 40) {
Rpay = hours * rate;
Opay = 0;
} else {
double Rhr, Ohr;
Rhr = 40;
Ohr = hours - Rhr;
Rpay = Rhr * rate;
Opay = Ohr * (1.5 * rate);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name;
int shift = 0;
Double rate, hours;
System.out.println("Pay Calculator");
String ch = "";
//added loop here to take the inputs repetedly
do {
System.out.println("Enter Your Name");
name = sc.next();
System.out.println("Enter Your Shift, Enter 0 for Day, Enter1 for
Night");
System.out.println("0=Day, 1= Night");
shift=sc.nextInt();
System.out.println("Enter Number of Hours Worked");
hours = sc.nextDouble();
System.out.println("Enter Hourly Pay");
rate = sc.nextDouble();
SalaryCalc c = new SalaryCalc();
c.calPay(hours, rate);
Double Tpay = c.Rpay + c.Opay;
System.out.println();
System.out.println("Calculate Pay");
System.out.println("Employee Name: " + name);
System.out.println("Employee Regular Pay: " + c.Rpay);
System.out.println("Employee Overtime Pay: " + c.Opay);
System.out.println("Employee Total Pay: " + Tpay);
if (shift == 0) {
System.out.println("Employee PayPeriod is Friday");
} else {
System.out.println("Employee PayPeriod is Saturday");
}
//asking user if they want to continue to enter another employee
data
System.out.println("Press Y to continue.Other key to exit ");
ch=sc.next();
} while (ch.equalsIgnoreCase("y"));
}
}
In: Computer Science
***This is done with Java programming***
Write a well-documented (commented) program, “ISBN,” that takes a 9-digit integer as a command-line argument, computes the checksum, and prints the ISBN number.
You should use Java’s String data type to implement it. The International Standard Book Number (ISBN) is a 10-digit code that uniquely specifies a book. The rightmost digit is a checksum digit that can be uniquely determined from the other 9 digits, from the condition that d1 + 2d2 +3d3 + ... + 10d10 must be a multiple of 11 (here di denotes the ith digit from the right).
The checksum digit d1 can be any value from 0 to 10. The ISBN convention is to use the character X to denote 10. The checksum digit corresponding to 032149805 is 4 since 4 is the only value of x between 0 and 10 (both inclusive), for which 10·0 + 9·3 + 8·2 + 7·1 + 6·4 + 5·9 +4·8 +3·0 + 2·5 + 1·x is a multiple of 11.
Sample runs would be as follows.
>java ISBN 013376940
The ISBN number would be 0133769402
>java ISBN 013380780
The ISBN number would be 0133807800
***This is done with Java programming***
In: Computer Science
how to read a csv file in php and make a html table?
Acme,Walmart,Ross,BJs,Target,Marshalls,Foot Locker,Giant,Charming Charlie
142,160,28,10,5,3,60,0.28,3167
175,180,18,8,4,1,12,0.43,4033
129,132,13,6,3,1,41,0.33,1471
138,140,17,7,3,1,22,0.46,3204
232,240,25,8,4,3,5,2.05,3613
135,140,18,7,4,3,9,0.57,3028
150,160,20,8,4,3,18,4.00,3131
207,225,22,8,4,2,16,2.22,5158
271,285,30,10,5,2,30,0.53,5702
89,90,10,5,3,1,43,0.30,2054
153,157,22,8,3,3,18,0.38,4127
87,90,16,7,3,1,50,0.65,1445
234,238,25,8,4,2,2,1.61,2087
106,116,20,8,4,1,13,0.22,2818
175,180,22,8,4,2,15,2.06,3917
165,170,17,8,4,2,33,0.46,2220
166,170,23,9,4,2,37,0.27,3498
136,140,19,7,3,1,22,0.63,3607
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Stores</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Stores</h1>
<?php
<table>
<tr>
<th>Acme</th>
<th>Walmart</th>
<th>Ross</th>
<th>BJs</th>
<th>Target</th>
<th>Marshalls</th>
<th>Foot Locker</th>
<th>Giant</th>
<th>Charming Charlie</th>
</tr>
$Stores = fopen("stores.csv", "r");
<tr>
<td>$Acme</td>
<td>$Walmart</td>
<td>$Ross</td>
<td>$BJs</td>
<td>$Target</td>
<td>$Marshalls</td>
<td>$Foot Locker</td>
<td>$Giant</td>
<td>$Charming Charlie</td>
</tr>
print "</table>";
?>
</body>
</html>
In: Computer Science
1. The development of a forensic lab for computers and mobile devices involves numerous specialized tools. Describe both hardware and software tools that might be utilized in such a lab.
2. Select ONE type of software tool from the list below. Using the internet or online library, find an article, case study, or publication about computer forensics that addresses the specific software tool you chose.
1) Device Seizure by Paraben
2) ForensicSIM by Evidence Talks
3) USIMdetective by Quantaq Solutions
4) SIMCON by Inside Out Forensics
5).XRY by Micro Systemation
6) MOBILedit! Forensic by Compelson Laboratories
In: Computer Science
A.Write a program that prompts for and reads the user’s first and last name (separately).Then print the initials with the capital letters. (Note that we do not expect that inputs from users are case-sensitive. For example, if the user’s input of the first name is robert and of the last name is SMITH, you should print R.S.)
B.Write a program that creates and prints a random phone number of the form XXX-XXX-XXXX. Include the dashed in the output. Do not let the first three digit contain an 8 or 9 (but don’t be more restrictive than that), and make sure that the second set of three digits is not greater than 655. Hint: Think through the easiest way to construct the phone number. Each digit does not have to be determined separately.
-use java
In: Computer Science
Rewrite the query methods used in the JS statements in lines 17, 18, 19, and 20 by using querySelector() or querySelectorAll() methods. Note that your code has to return the same outputs on the console (in a browser's developer tab, Ctrl + Shift + J) before you make the changes.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Access HTML elements </title>
</head>
<body>
<section id="main">
<h1>The 2011-2012 Speaker
Lineup </h1>
<p class="blue">October 19,
2011: Jeffrey Toobin </p>
<p class="blue">November 16,
2011: Andrew Ross Sorkin </p>
</section>
<footer>
<p class="right">Copyright
2012 </p>
</footer>
<script>
var sec =
document.getElementById('main');//return the <section>
element which has id="main"
var list1 =
document.getElementsByTagName('p');//return the HTMLCollection
object containing 3 <p> elements that belongs to
class="blue"
var list2 =
sec.getElementsByTagName('p');//return the HTMLCollection object
containing 2 <p> elements
var list3 =
sec.getElementsByClassName('blue'); ////return the HTMLCollection
object containing 2 <p> elements in the <section>
element
console.log(sec);
console.log(list1);
console.log(list2);
console.log(list3);
</script>
</body>
In: Computer Science
An Euler Circuit is a circuit that crosses every edge exactly once without repeating. A graph has an Euler Circuit if and only if (a) the graph is connected and (b) the degree of every vertex is even. Find a lower bound for the time complexity of all algorithms that determine if a graph has an Euler Circuit. In which of the three general categories discussed in Section 9.3 does this problem belong? Justify your answer.
In: Computer Science
Using C #
Problem: "Tom is from the U.S. Census Bureau and greets Mary at her
door. They have the following conversation: Tom: I need to know how
old your three kids are. Mary: The product of their ages is 36.
Tom: I still don't know their ages. Mary: The sum of their ages is
the same as my house number. Tom: I still don't know their ages.
Mary: The younger two are twins. Tom: Now I know their ages!
Thanks! How old are Mary's kids and what is Mary's house
number?"
The solution is 2,2,9, therefore mary's house # is 13
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This is the code i have thus far:
Console.WriteLine("What is the age of the first child");
num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("What is the age of the second child");
num2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("What is the age of the third child");
num3 = Convert.ToInt32(Console.ReadLine());
How do I make it loop until they get the correct answer. (2,2,9) or (2,9,2) or (9,2,2)
If they get the answer wrong, I want the user keep trying again until they enter "quit"
In: Computer Science
(35 pt.) Prove that the following languages are not regular using the pumping lemma.
(15pt.)?={?????? |?,?≥?}
(20 pt.) ? = {? ∈ {?, #}∗ | ? = ??#??# ... #?? ??? ? ≥ ?, ?? ∈
?∗ ??? ????? ?, ??? ?? ≠?? ???????? ?≠?}
Hint: choose a string ? ∈ ? that contains ? #’s.
In: Computer Science
need new and unique answers, please. (Use your own words, don't copy and paste), Please Use your keyboard (Don't use handwriting) Thank you..
The data warehouse is one of the most important business intelligence tools a business needs to have. It turns the massive amount of data generated from multiple sources into a format that is easy to understand. Discuss the data warehouse concept?
In: Computer Science