There are four basic functions in math. They are addition, subtraction, multiplication and division. Children in 1st grade focus on addition. They are required to memorize their addition facts from 1 to 12.
Create a function that prompts the user to enter a number between 1 and 12. Then display - using the input supplied - the addition and subtraction math facts for that number from 1 to 12 for the number entered. The output should be the results of the mathematical calculations.
See below example below:
The user enters "5" as their input. Below is the expected output.
Addition Math Facts for "5"
5 + 1 = 6
5 +2 = 7
...
5 + 11 = 16
5 + 12 = 17
Subtraction Math Facts for "5"
12 - 5 =
11 - 5 =
10 - 5 =
...
7 - 5 = 2
6 - 5 = 1
5 - 5 = 0
* Please note the subtraction facts should stop at the input number - the input number because 1st graders are not prepared to learn about negative numbers.
If the user enters a number not between 1 and 12, open an alert window stating that it is an invalid number, and prompt them to enter a number again meeting the criteria. Finally, if the number entered is bellow 6, make the background color blue and the text white, if the number is above 6 make the background color red and the text yellow, and if the number is six then make the background color white and the text black.
* must use HTML and java script. Must make program in brackets.
HINT: use a variable and a window.prompt() to store what the person enters, a conditional statement, and string concatenation using HTML .
In: Computer Science
Concert the following 32-bit floating point number (IEEE single precision) into their decimal representation.
1100 0101 0001 1111 1000 0000 0000 0000 (ANSW: -2552.0)
Please show all work
In: Computer Science
How cold is it outside? The temperature alone is not enough to provide the answer. Other factors including wind speed, relative humidity, and sunshine play important roles in determining coldness outside. In 2001, the National Weather Service (NWS) implemented the new wind-chill temperature to measure the coldness using temperature and wind speed. The formula is:
twc = 35.74 + 0.6215ta - 35.75v0.16 + 0.4275tav0.16
t w c = 3.74 + 0.6215 t a − 35.75 v 0.16 + 0.4275 t a v 0.16
where ta is the outside temperature measured in degrees Fahrenheit, v is the speed measured in miles per hour, and twc is the wind-chill temperature. The formula cannot be used for wind speeds below 2mph or temperatures below -58°F or above 41°F.
Write a program that prompts the user to enter a temperature between -58°F and 41°F and a wind speed greater than or equal to 2 then displays the wind-chill temperature. Use Math.pow(a, b) to compute v0.16. Your class must be named Windchill. Here is a sample run:
Enter a temperature between -58°F and 41°F: 5.3 Enter the wind speed (>= 2) in miles per hour: 6 The wind chill index is -5.567068455881625
This is what I made:
import java.util.Scanner;
public class Windchill
{
public static void main(String[]args)
{
//create Scanner
Scanner s=new Scanner(System.in);
double ta= 5.3;
int v= 6;
double v2= Math.pow(v,.16);
double Windchill= 35.74 + 0.6215 * ta-35.75 * v2+0.4275 * ta *
v2;
//get temperature in Fahrenheit
System.out.println("Enter a temperature between -58°F and 41°F:" +"
"+ ta);
//get wind speed
System.out.println("Enter the wind speed (>= 2) in miles per
hour"+" "+ v);
//get windchill index
System.out.println("The windchill index is"+" "+ Windchill);
}
}
My teacher told me: "your program needs to let the user enter the temperature and wind speed at the keyboard."
How do I fix this? please help.
In: Computer Science
public class N extends String, Integer
{
}
When you compile, you get the following message:
N.java:1: ‘{‘ expected
public class N extends String, Integer
^
1 error
Explain what the problem is and how to fix it.
In: Computer Science
Generating secure password that you can remember, lab2pr0.py
It’s not easy
to come up with a secure password that one can actually remember.
One of the
methods proposed is to take a line of text and take first letter of
each word to form
a password. An extra step is substitute ”o” with 0, ”a” with ”@”,
and ”l” with
1. For instance, using ”Cookies and Code, let’s meet on Tuesdays”
would yield
”C@C,1m0T”. Write a program that asks the user to enter a phrase
and outputs
the password that is generated using these rules.
You can assume that the words in the phrase will be separated by a
single space or
a common punctuation sign such as ”.,?!;:” followed by a space.
use python
In: Computer Science
Pizza analysis, lab3pr1.py You noticed that the menu of your favorite pizza
chain store is rather complicated. They offer a range of pizza
size and price op-
tions, making it difficult to see what option offers the most pizza
for your dol-
lars. So you decide to write program that calculates the cost per
square inch
of a circular pizza, given its diameter and price, similar to
how grocery stores
display cost-per-ounce prices. The formula for area is A = r
2 ∗ π. Use two func-
tions: one called area(radius) to compute the area of a pizza, and
one called
cost per inch(diameter, price) to compute cost per square inch.
Sample runs
of your program should look like this:
Please enter the diameter of your pizza, in inches: 20
Please enter its cost, in dollars: 20
The cost is 0.06 dollars per square inch.
>>>>
Please enter the diameter of your pizza, in inches: 8.5
Please enter its cost, in dollars: 12.99
The cost is 0.23 dollars per square inch.
Use the built-in Python function round(value, 2) to round the
final cost-per-
inch value to two decimal points. Use import math and math.pi to
get the value
of pi for area computation.
use python
In: Computer Science
In: Computer Science
Develop and pseudocode for the code below:
#include <algorithm>
#include <iostream>
#include <time.h>
#include "CSVparser.hpp"
using namespace std;
//============================================================================
// Global definitions visible to all methods and classes
//============================================================================
// forward declarations
double strToDouble(string str, char ch);
// define a structure to hold bid information
struct Bid {
string bidId; // unique identifier
string title;
string fund;
double amount;
Bid() {
amount = 0.0;
}
};
//============================================================================
// Static methods used for testing
//============================================================================
/**
* Display the bid information to the console (std::out)
*
* @param bid struct containing the bid info
*/
void displayBid(Bid bid) {
cout << bid.bidId << ": " << bid.title << "
| " << bid.amount << " | "
<< bid.fund << endl;
return;
}
/**
* Prompt user for bid information using console (std::in)
*
* @return Bid struct containing the bid info
*/
Bid getBid() {
Bid bid;
cout << "Enter Id: ";
cin.ignore();
getline(cin, bid.bidId);
cout << "Enter title: ";
getline(cin, bid.title);
cout << "Enter fund: ";
cin >> bid.fund;
cout << "Enter amount: ";
cin.ignore();
string strAmount;
getline(cin, strAmount);
bid.amount = strToDouble(strAmount, '$');
return bid;
}
/**
* Load a CSV file containing bids into a container
*
* @param csvPath the path to the CSV file to load
* @return a container holding all the bids read
*/
vector<Bid> loadBids(string csvPath) {
cout << "Loading CSV file " << csvPath <<
endl;
// Define a vector data structure to hold a collection of
bids.
vector<Bid> bids;
// initialize the CSV Parser using the given path
csv::Parser file = csv::Parser(csvPath);
try {
// loop to read rows of a CSV file
for (int i = 0; i < file.rowCount(); i++) {
// Create a data structure and add to the collection of
bids
Bid bid;
bid.bidId = file[i][1];
bid.title = file[i][0];
bid.fund = file[i][8];
bid.amount = strToDouble(file[i][4], '$');
//cout << "Item: " << bid.title << ", Fund: " << bid.fund << ", Amount: " << bid.amount << endl;
// push this bid to the end
bids.push_back(bid);
}
} catch (csv::Error &e) {
std::cerr << e.what() << std::endl;
}
return bids;
}
// FIXME (2a): Implement the quick sort logic over bid.title
/**
* Partition the vector of bids into two parts, low and high
*
* @param bids Address of the vector<Bid> instance to be
partitioned
* @param begin Beginning index to partition
* @param end Ending index to partition
*/
int partition(vector<Bid>& bids, int begin, int end)
{
int l = begin;
int h = end;
int pivot = (begin + (end - begin) / 2);
bool finished = false;
// this while loops continually increments the low point as long
as it's below the pivot
// then continually decrements the high point as long as it's above
the pivot
while(!finished) {
while(bids[l].title.compare(bids[pivot].title) < 0) {
++l;
}
while(bids[pivot].title.compare(bids[h].title) < 0) {
--h;
}
if (l >= h) {
finished = true;
// if variable l is not greater than or equal to h the two bids are
swapped
} else {
swap(bids[l] , bids[h]);
//bring end points closer to one another
++l;
--h;
}
}
return h;
}
/**
* Perform a quick sort on bid title
* Average performance: O(n log(n))
* Worst case performance O(n^2))
*
* @param bids address of the vector<Bid> instance to be
sorted
* @param begin the beginning index to sort on
* @param end the ending index to sort on
*/
void quickSort(vector<Bid>& bids, int begin, int end)
{
}
// FIXME (1a): Implement the selection sort logic over bid.title
/**
* Perform a selection sort on bid title
* Average performance: O(n^2))
* Worst case performance O(n^2))
*
* @param bid address of the vector<Bid>
* instance to be sorted
*/
void selectionSort(vector<Bid>& bids) {
// this creates an index to the smallest minimum bid found
unsigned int smallest;
unsigned int largest = bids.size();
// place designates the position at which bids are
sorted/unsorted
for (unsigned place = 0; place < largest; ++place) {
smallest = place;
for (unsigned j = place + 1; j < largest; ++j) {
if (bids[j].title.compare(bids[smallest].title) < 0) {
smallest = j;
}
}
if (smallest != place)
swap(bids[place], bids[smallest]);
}
}
/**
* Simple C function to convert a string to a double
* after stripping out unwanted char
*
* credit: http://stackoverflow.com/a/24875936
*
* @param ch The character to strip out
*/
double strToDouble(string str, char ch) {
str.erase(remove(str.begin(), str.end(), ch), str.end());
return atof(str.c_str());
}
/**
* The one and only main() method
*/
int main(int argc, char* argv[]) {
// process command line arguments
string csvPath;
switch (argc) {
case 2:
csvPath = argv[1];
break;
default:
csvPath = "eBid_Monthly_Sales_Dec_2016.csv";
}
// Define a vector to hold all the bids
vector<Bid> bids;
// Define a timer variable
clock_t ticks;
int choice = 0;
while (choice != 9) {
cout << "Menu:" << endl;
cout << " 1. Load Bids" << endl;
cout << " 2. Display All Bids" << endl;
cout << " 3. Selection Sort All Bids" << endl;
cout << " 4. Quick Sort All Bids" << endl;
cout << " 9. Exit" << endl;
cout << "Enter choice: ";
cin >> choice;
switch (choice) {
case 1:
// Initialize a timer variable before loading bids
ticks = clock();
// Complete the method call to load the bids
bids = loadBids(csvPath);
cout << bids.size() << " bids read" << endl;
// Calculate elapsed time and display result
ticks = clock() - ticks; // current clock ticks minus starting
clock ticks
cout << "time: " << ticks << " clock ticks"
<< endl;
cout << "time: " << ticks * 1.0 / CLOCKS_PER_SEC
<< " seconds" << endl;
break;
case 2:
// Loop and display the bids read
for (int i = 0; i < bids.size(); ++i) {
displayBid(bids[i]);
}
cout << endl;
break;
// FIXME (1b): Invoke the selection sort and report timing
results
ticks = clock();
// call selectionSort method to sort the loaded bids
selectionSort(bids);
cout << bids.size() << " bids read" << endl;
// Calculate elapsed time and display result
ticks = clock() - ticks; // current clock ticks minus starting
clock ticks
cout << "time: " << ticks << " clock ticks"
<< endl;
cout << "time: " << ticks * 1.0 / CLOCKS_PER_SEC
<< " seconds" << endl;
break;
// FIXME (2b): Invoke the quick sort and report timing results
ticks = clock();
// call quickSort method to sort the loaded bids
quickSort(bids, 0, bids.size() - 1);
cout << bids.size() << " bids read" << endl;
// Calculate elapsed time and display result
ticks = clock() - ticks; // current clock ticks minus starting
clock ticks
cout << "time: " << ticks << " clock ticks"
<< endl;
cout << "time: " << ticks * 1.0 / CLOCKS_PER_SEC
<< " seconds" << endl;
break;
}
cout << "Good bye." << endl;
return 0;
}
In: Computer Science
Implement a simple banking system in Java. Your application should demonstrate the following. Upon running the java code, first the application should welcome the user, then ask the user to give one of the options: 1) display the balance summary, 2) withdraw money, or 3) deposit money.
Based on the options your code should perform the following operations such as 1) read the transaction details from a file and display them on the screen. 2) ask the user to enter the amount he wants to withdraw and debit the withdrawal amount from the balance amount. It has to update the file and display the transaction summary. The system should not allow an attempt to withdraw an amount greater than the balance. 3) ask the user to enter the amount he wants to deposit, credit the balance and update the file. It should display the transaction summary.
The records in the file should contain transaction number,
transaction type, amount withdrawn, or amount deposited, and
balance.
Example:
1 Deposit 100.0$ 1100.0$
2 Withdraw 50.0$ 1050.0$
The welcome screen should look like:
Welcome to our Banking System!
Enter your Option in a number: 1. Display balance 2. Deposit amount
3. Withdraw amount
We assume that there is an opening balance of 1000 available in the
system (Assign balance=1000.0 in the beginning of the code). Also,
while running first start by choosing deposit option or withdraw
option.
In: Computer Science
Privacy program, lab2pr2.py Write an automated password-hiding
program that
could be used in automatic password manager. The program will first
read user
passwords, one at a time, and store them in a list. When the user
enters an empty
string (just hits enter), they are finished with the input. The
program should
then replace each password with a string of * corresponding to the
length of the
original password. As the output, the program should print the
original list and
the resulting list.
For instance, here’s the output from a sample run of your
program:
Please enter a password (press [enter] to finish): Tulane123
Please enter a password (press [enter] to finish): Bruff
Please enter a password (press [enter] to finish): LBCLBC
Please enter a password (press [enter] to finish):
[’Tulane123’, ’Bruff’, ’LBCLBC’]
[’*********’, ’*****’, ’******’]
use python
In: Computer Science
In the United States, a Social Security number (SSN) is a
nine-digit number that
is a national identification number for taxation purposes. Write a
program that
asks the user for their social security number in DDDDDDDDD format
(where
D is digit). The program first performs a basic check if the number
corresponds
to actual SSN by making sure it has 9 characters in it. If yes, it
creates a string
variable new ssn with SSN in user-friendly DDD − DD − DDDD format
and
prints it. If not, it prints an error message Incorrect SSN
length.
use python
In: Computer Science
In C++
A new author is in the process of negotiating a contract for a new romance novel. The publisher is offering three options.
The author has some idea about the number of copies that will be sold and would like to have an estimate of the royalties generated under each option.
Instructions
Write a program that prompts the author to enter:
The program then outputs:
(Use appropriate named constants to store the special values such as royalty rates and fixed royalties.)
Since your program handles currency, make sure to use a data type that can store decimals with a decimal precision of 2.
Example input:
120 22.99
Expected Output:
25000.0
344.8
275.8
Option 1 is the best
In: Computer Science
in java. using the following template as a method, public static void shellSort(int[] array) {
create a program that counts the number of comparisons and swaps of the sorting method does using
int array1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // Best Case Test int array2[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; // Worst Case Test int array3[] = {10, 4, 8, 2, 6, 1, 9, 3, 7, 5}; // Average Case Test
and have the counsel print out the results.
In: Computer Science
What kind of network management protocols are available? What information can these protocols provide? Explain it with example.
In: Computer Science
What kind of network management protocols are available? What information can these protocols provide? Explain it with example. Note: NEED A UNIQUE ANSWER AND NO HANDWRITING PLEASE..
In: Computer Science