convert 0x41BA8000 to IEEE-754 floating-point value
In: Computer Science
Write a JavaFX application that presents a button and a circle. Every time the button is pushed, the circle should be moved to a new random location within the window.
This must only be one .java file. I cannot use
import javafx.geometry.Insets;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.HBox;
This is what I have so far:
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class CircleJumper extends Application
{
public double circlePositionX = 300;
public double circlePositionY = 300;
@Override
public void start(Stage primaryStage)
{
Circle circle = new Circle(circlePositionX, circlePositionY,
70);
circle.setFill(Color.BLUE);
//create button to create new circle
Button push = new Button("PRESS!");
push.setOnAction(this::processButtonPress);
Group root = new Group(circle, push);
Scene Scene = new Scene(root, 700, 500, Color.WHITE);
primaryStage.setTitle("Circle
Jumper"); // Set the stage title
primaryStage.setScene(Scene); //
Place the scene in the stage
primaryStage.show(); // Display the
stage
}
public void processButtonPress(ActionEvent event)
{
Circle circle = new Circle(Math.random(), Math.random(), 50);
circle.setFill(Color.BLUE);
Group root = new Group(circle);
Scene Scene = new Scene(root, 700, 500, Color.WHITE);
}
public static void main(String[] args)
{
launch(args);
}
In: Computer Science
Then try:
***
ADDITIONAL NOTES IN CASE YOU ARE HAVING I/O TROUBLES:
//Writing from your Source Code to an External .txt File:
PrintWriter outputFile = new
PrintWriter("names.txt");
outputFile.println("Mike");
outputFile.close();
*************
//Appending from your Source Code to an External .txt File:
FileWriter fileWrite = new FileWriter("names.txt", true);
PrintWriter outWrite = new PrintWriter(fileWrite);
outWrite.println("John");
outWrite.close();
*************
//Reading from an external .txt File into your Source Code:
File myFile = new File("Customers.txt");
Scanner inputFile = new Scanner(myFile);
String str = inputFile.nextLine();
inputFile.close();
In: Computer Science
Use Java to rewrite the following pseudo-code segment using a loop structure without goto, break, or any other unconditional branching statement:
k = (j+13)/27; //assume i,j,k are integers properly declared.
loop:
if k > 10 then goto out
k=k+1.2;
i=3*k-1;
goto loop;
out: …
In: Computer Science
Given the Linux shell command descriptions, please write down the corresponding shell commands in a terminal window.
a) list the current directory contents with the long format
b) print the name of the working directory
c) change directory to the root directory
d) change the permissions of file "myfile" (owned by yourself) so that (1)you can read/write, but cannot execute; (2) all other users cannot read/write/execute this file.
e) make a new directory called “mydir”
In: Computer Science
Are you planning to allow clients to ACCESS YOUR RAW DATA (Big Data) or are you planning on analyzing that Big Data and presenting FINISHED ANALYTICS to clients?? If you are planning on allowing many many customers to access your data, then how big is your helpdesk and how big does your network throughput need to be to allow customer-access? And what about Security? If you're mostly in the cloud - is your CSP going to provide sufficient security? If you are mostly NOT in the cloud - what's your general plan for Security?
In: Computer Science
Q1) Create a function called max that receives two integer values and returns the value of the bigger integer.
Q2) Complete the missing code in the following program. Assume that a cosine function has already been created for you. Consider the following function header for the cos function. double cos (double x) #include void output_separator() { std::cout << "================"; } void greet_name(string name) { std::cout << "Hey " << name << "! How are you?"; } int sum(int x, int y){ return x + y; } int main() { std::string name; int num1, num2, result; double num_dec, result_dec; std::cout << "Please enter your name: "; std::cin >> name; Answer ; // call the greet_name function and pass the user's name Answer ; // call the output_separator function std::cout << "Please input 2 integer values: "; std::cin >> num1 >> num2; std::cout << "Please input a double value: "; std::cin >> num_dec; std::cout << "Here are the results of my function test"; Answer ; // store the result of the sum function into // result and pass num1 and num2 as parameters std::cout << "Sum result: " << result; Answer ; // store the result of the cos function into // result_dec and pass num_dec as the parameter std::cout << "Cosine result: " << result_dec; return 0; }
In: Computer Science
PYTHON
The nth term of the sequence is given by: Xn = (2 ∗ Xn-3) +Xn-2+/ + (4 ∗ Xn-1)
For example, if the first three values in the sequence were 1, 2 and 3. The fourth value would be: (2 * 1) + 2 + (4 * 3) = 16 Replacing the previous three Integers (2, 3 and 16) in the formula would determine the fifth value in the sequence. The nth term can be calculated by repeating this process. Write a program that includes two functions main() and calculate()which are used to determine the nth term in the sequence.
The main() function: • Displays a description of the program’s function • Prompts the user for the number of values in the sequence (n) • Prompts the user for the first three values in the sequence • Using a loop, calls the calculate() function repeatedly until the nth value is determined • Displays the nth value of the sequence
The calculate() function: • Accepts three values as arguments • Calculates the next value in the sequence • Returns the calculated value
In: Computer Science
Complete these steps to write a simple calculator program:
1. Create a calc project directory
2. Create a mcalc.c source file containing five functions; add, sub, mul, div, and mod; that implement integer addition, subtraction, multiplication, division, and modulo (remainder of division) respectively. Each function should take two integer arguments and return an integer result.
3. Create a mcalc.h header file that contains function prototypes for each of the five functions implemented in mcalc.c.
4. Create a calc.c source file with a single main function that implements a simple calculator program with the following behavior:
-> Accepts a line of input on stdin of the form ”number operator number” where number is a signed decimal integer, and operator is one of the characters ”+”, ”-”, ”*”, ”/”, or ”%” that corresponds to the integer addition, subtraction, multiplication, division, and modulo operation respectively.
-> Performs the corresponding operation on the two input numbers using the five mcalc.c functions.
-> Displays the signed decimal integer result on a separate line and loops to accept another line of input.
-> Or, for any invalid input, immediately terminates the program with exit status 0.
5. Create a Makefile using the following Makefile below as a starting point. Modify the Makefile so that it builds the executable calc as the default target. The Makefile should also properly represent the dependencies of calc.o and mcalc.o.
CC = gcc
CFLAGS = -g -O2 -Wall -Werror
ASFLAGS = -g
objects = calc.o mcalc.o
default: calc
.PHONY: default clean clobber
calc: $(objects)
$(CC) -g -o $@ $^
calc.o: calc.c mcalc.h
%.o: %.c
$(CC) -c $(CFLAGS) -o $@ $<
%.o: %.s
$(CC) -c $(ASFLAGS) -o $@ $<
clean:
rm -f $(objects)
clobber: clean
rm -f calc
6. Compile the calc program by executing ”make” and verify that the output is proper. For example:
# ./calc
3 + 5
8
6 * 7
42
In: Computer Science
Write and test a python program to demonstrate TCP server and client connections. The client sends a Message containing the 10 float numbers (FloatNumber[]) , and then server replies with a message containing maximum, minimum, and average of these numbers.
In: Computer Science
I need this code translated to C code. Thank you.
public class FourColorTheorem {
public static boolean isPrime(int num) {
// Corner case
if (num <= 1)
return false;
// Check from 2 to n-1
for (int i = 2; i < num; i++)
if (num % i == 0)
return false;
return true;
}
public static void main(String[] args) {
int squares[] = new int[100];
for (int i = 1; i < squares.length; i++) squares[i-1] = i *
i;
int n = 5;
while (true) {
boolean flag = false;
for (int i = 0; i < squares.length; i++) {
int difference = n - 2 * squares[i];
if (isPrime(difference)) {
flag = true;
// you can comment the below line
System.out.println(n + " = " + difference + " + 2*" +
Math.sqrt(squares[i]) + "*" + Math.sqrt(squares[i]));
break;
}
}
if (!flag) {
break;
}
n += 2;
}
System.out.println("Smallest counter example = " + n);
}
}
In: Computer Science
In the PDF file that will contain your screen shots, explain what is wrong with the code below. Do not just state thing like “line 3 should come after line 7,” you must explain why it needs to be changed. This shows that you are fully understanding what we are going over.
// This program uses a switch-case statement to assign a
// letter grade (A, B, C, D, or F) to a numeric test score.
#include <iostream>
using namespace std;
int main()
{
double testScore;
cout<< "Enter your test score and I will tell you\n";
cout<<"the letter grade you earned: ";
cin>> testScore;
switch (testScore)
{
case (testScore < 60.0):
cout << "Your grade is F. \n";
break;
case (testScore < 70.0):
cout << "Your grade is D. \n";
break;
case (testScore < 80.0):
cout << "Your grade is C. \n";
break;
case (testScore < 90.0):
cout << "Your grade is B. \n";
break;
case (testScore < 100.0):
cout << "Your grade is A. \n";
break;
default:
cout << "That score isn't valid\n";
return 0;
}
In: Computer Science
(PYTHON) Write a program:
This assignment will give you more experience on the use of:
1. integers (int)
2. floats (float)
3. conditionals
4. iteration
The goal of this project is to make a fictitious comparison of the federal income. You will ask the user to input their taxable income. Use the income brackets given below to calculate the new and old income tax. For the sake of simplicity of the project we will only consider individuals and not married users. We will also ignore any tax deductions while calculating income tax they can significantly alter the tax, but add too much complexity for our programming project.
New income tax brackets (2018 and newer)
Rate Income range
10% Up to $9,525
12% $9,526 to $38,700
22% $38,701 to $82,500
24% $82,501 to $157,500
32% $157,501 to $200,000
35% $200,001 to $500,000
37% over $500,000
Old income tax brackets (2017 and older)
Rate Income range
10% Up to $9,325
15% $9,326 to $37,950
25% $37,951 to $91,900
28% $91,901 to $191,650
33% $191,651 to $416,700
35% $416,701 to $418,400
39.6% over $418,401
Assignment Background
Being in the 25% tax bracket doesn’t mean you pay 25% on everything you make. The progressive tax system means that people with higher taxable incomes are subject to higher tax rates, and people with lower taxable incomes are subject to lower tax rates.
For example, let’s say you’re a filer with $32,000 in taxable income. That puts you in the 15% tax bracket in 2017. But do you pay 15% on all $32,000? No. Actually, you pay only 10% on the first $9,325; you pay 15% on the rest. (Look at the tax brackets above to see the breakout.) If you had $50,000 of taxable income, you’d pay 10% on that first $9,325 and 15% on the chunk of income between $9,326 and $37,950. And then you’d pay 25% on the rest, because some of your $50,000 of taxable income falls into the 25% tax bracket. The total bill would be $8,238.75 — about 16% of your taxable income, even though you’re in the 25% bracket.
Project Description
Your program must meet the following specifications:
1. At program start, prompt the user for their income
2. Repeatedly prompt the user for new income until a negative income is entered.
3. Calculate the income tax using the 2017 and 2018 tax bracket tables above.
4. For each income entered:
a. Calculate the 2017 income tax and store it in a variable.
b. Next calculate the 2018 income tax and store it in a variable
c. Print
i. The income
ii. The 2017 tax
iii. The 2018 tax
iv. The difference between the 2018 and 2017 tax rounded to cents.
v. The difference between the 2018 and 2017 tax as a percentage of the 2017 tax rounded to cents
Assignment Notes
1. To clarify the project specifications, sample output is appended to the end of this document.
2. Use a while loop with a Boolean that keeps looping as long as the income is greater than or equal to zero. Prompt for income before the loop and remember to convert the input string to an int (so you are comparing an int in your Boolean expression). Remember to prompt again at the end (aka “bottom”) of the loop.
4. There will be no error checking in this assignment. If a float or a string is entered at the prompt, the program will crash.
In: Computer Science
In: Computer Science
C++
For this assignment, you will write a C++ program to either add (A), subtract (S), multiply (M), and (N), or (O) two matrices if possible. You will read in the dimensions (rows, then columns) of the first matrix, then read the first matrix, then the dimensions (rows then columns) of the second matrix, then the second matrix, then a character (A, S, M, N, O) to determine which operation they want to do.
The program will then perform the operation, print the answer,
and quit. The program should have five functions in addition to
main - one for add, one for subtract, one for multiply, one for
add, and one for or, but main should do all the input and output.
Matrices will be no bigger than 10x10 and will be ints. You cannot
assume the matrices will be square.
SAMPLE:
$ ./a.out input the row size and col size of A 3 2 input matrix A 2 1 -1 0 3 4 input the row size and col size of B 3 2 input matrix B 12 -18 3 9 6 -3 Choose your operation: A for add, S for subtract, M for multiply N for and, O for or A The answer is: 14 -17 2 9 9 1
In: Computer Science