using Java;
In Scrabble, each player has a set of tiles with letters on them. The object of the game is to use those letters to spell words. The scoring system is complex, but longer words are usually worth more than shorter words. Imagine you are given your set of tiles as a string, like "quijibo", and you are given another string to test, like "jib". Write a method called canSpell that takes two strings and checks whether the set of tiles can spell the word. You might have more than one tile with the same letter, but you can use each tile only once.
In: Computer Science
Python...Count the number of times a element of list1
occurs in in list2
list1 = ['a', 'b', 'c','e','j'];
list2 = ['a', 'c', 'd', 'b','e','z'];
{'a': 1, 'c': 1, 'b': 1, 'e': 1, 'j': 0}
How do I get to this to work without the Collections counter?
In: Computer Science
Insertion sort, which is one of the other sorting
techniques introduced in this chapter. Create an algorithm to
implement an insertion sort.
Methods for sorting data files. You should produce a
brief report discussing the different sorting options that can be
used.
In: Computer Science
Write a script that will output a table where the rows and cells are labeled. The script should be versatile, so one could easily change the number of rows and cells the script should output. For this exercise have the script create a table with 15 rows and 5 cells. Refer to the tables lesson for information on how to create a table. You need to write all the PHP functionality above the doctype and display the resulting HTML string via a variable in the echo statement within the body element
In: Computer Science
Discuss the issues involved in sorting large data
files. Explain how indexing is used to overcome this
issue.
Explain the difference between physical order and
logical order
In: Computer Science
*** In C++
Write a program that converts from 24-hour notation to 12-hour notation. For example, it should convert 14:25 to 2:25 P.M. The input is given as two integers.
This is what I have so far. The program runs for correct input values, but I cannot figure out how to accommodate for hours > 23 and minutes > 59, or negative values. My code is below:
// Writing a program that converts from 24-hour notation to 12-hour notation.//
#include
using namespace std;
void input(int&, int&, char&);
void convert(int&, int&, char&);
void output(int&, int&, char&);
int main()
{
int hours, minutes;
char ampm; //character value to determine am/pm
char again; //run the program again
//loop for re-running program
do
{
input(hours, minutes, ampm);
convert(hours, minutes,
ampm);
output(hours, minutes, ampm);
cout << endl <<
"Enter Y to run again, or any other key to exit: ";
cin >> again;
}
while (again == 'y' || again == 'Y');
return 0;
}
void input(int& hours, int& minutes, char&
ampm)
{
//loop for input and checking for invalid input
cout << "Enter time in 24hr format HH:MM
";
cin >> hours;
cin.get();
cin >> minutes;
do
{
if (hours > 23 || hours < 0)
cout << "Please enter a value between 0 and 23" <<
endl;
}
while (hours > 23);
}
void convert(int& hours, int& minutes, char&
ampm)
{
//designates PM if hour is above 12, and reduces to
12hr format
//*** try >= to reduce to two lines
if (hours > 12)
{
hours = hours - 12;
ampm = 'p';
}
else if (hours == 12) ampm = 'p';
else ampm = 'a';
}
void output(int& hours, int& minutes, char&
ampm)
{
if (ampm == 'p')
{
if (minutes < 10) cout <<
hours << ":0" << minutes << " P.M.";
else cout << hours <<
":" << minutes << " P.M.";
}
else
{
if (minutes < 10) cout <<
hours << ":0" << minutes << " A.M.";
else cout << hours <<
":" << minutes << "A.M.";
}
}
In: Computer Science
#include <stdio.h> #define MAX 8 //Byte = 8 bits void func_and(int a[], int b[], int result[]) { for(int i=0; i < MAX; i = i + 1){ result[i] = a[i] & b[i]; } } void func_or(int a[], int b[], int result[]) { for(int i=0; i < MAX; i = i + 1){ result[i] = a[i] || b[i]; } } void func_not(int a[], int result[]) { for (int i = 0; i < MAX; i = i + 1) { result[i] = !a[i]; } } void func_1s_comp(int a[], int result[]) { for (int i = 0; i < MAX; i = i + 1) { result[i] = !a[i]; } } void func_2s_comp(int a[], int result[]) { for (int i = 0; i < MAX; i = i + 1) { result[i] = !a[i]; if(result[i] == '1' && carry == 1) { compTwo[i] = '0'; } else if(result[i] == '0' && carry == ddd1) { compTwo[i] = '1'; carry = 0; } else { compTwo[i] = result[i]; } compTwo[MAX] = '\0'; } } int main(void) { int choice; int carry = 1; int compTwo[]; int x[MAX]; int y[MAX]; int z[MAX]; do { printf("Enter the command number: \n0. Exit\n1. AND\n2. OR\n3. NOT\n4. 1's complement\n5. 2's complement\n6. 2's complement*\n"); scanf("%d", &choice); switch (choice) { case 0: //Exit break; case 1: //AND printf("Enter the first binary number: \n"); for (int i = 0; i < MAX; i = i + 1) { scanf("%d", &x[i]); } printf("Enter the second binary number: \n"); for (int i = 0; i < MAX; i = i + 1) { scanf("%d", &y[i]); } func_and(x, y, z); printf("The first number AND second binary yield: "); for (int i = 0; i < MAX; i = i + 1) { printf("%d", z[i]); } printf("\n"); case 2: //OR printf("Enter the first binary number: \n"); for (int i = 0; i < MAX; i = i + 1) { scanf("%d", &x[i]); } printf("Enter the second binary number: \n"); for (int i = 0; i < MAX; i = i + 1) { scanf("%d", &y[i]); } func_or(x, y, z); printf("The first number OR second binary yield: "); for (int i = 0; i < MAX; i = i + 1) { printf("%d", z[i]); } printf("\n"); case 3: //NOT printf("Enter the binary number: \n"); for (int i = 0; i < MAX; i = i + 1) { scanf("%d", &x[i]); } func_not(x, z); printf("The NOT for this number is: "); for (int i = 0; i < MAX; i = i + 1) { printf("%d", z[i]); } printf("\n"); case 4: //1's complement printf("Enter the binary number: \n"); for (int i = 0; i < MAX; i = i + 1) { scanf("%d", &x[i]); } func_1s_comp(x, z); printf("The 1st complement of this binary number is: "); for (int i = 0; i < MAX; i = i + 1) { printf("%d", z[i]); } printf("\n"); case 5://2's complement printf("Enter the binary number: \n"); for (int i = 0; i < MAX; i = i + 1) { scanf("%d", &x[i]); } func_2s_comp(x, z); printf("The 2nd complement of this binary number is: "); for (int i = 0; i < MAX; i = i + 1) { printf("%d", z[i]); } printf("\n"); case 6://2's complement* break; } } while (choice != 0); return 0; } I just have to add 2's complemenet and 2* complement which in the 2 functions which I dont know how to do. 2* complement is "Start from the right to left until you see digit 1, then pass it and NOT the digits after that. For instance, 2’s complement of 110100 is 001100"
In: Computer Science
Creating a list/tuple
3.Given a list of tuples containing student first names and last names e.g. (“John”, “Doe”) that represents a class. Ask the user for a students first and last name and check if that student is a member of the class.
In: Computer Science
Prove the following:
If a heap has one new leaf added that does not satisfy the condition that the leaf is greater than its parent, then sifting that leaf up until it is greater than its parent will produce a heap.
In: Computer Science
In: Computer Science
VI. Answer part A, B, and C of question 5.
5a)
Given a String str1 and a String str2, return true if str1 contains any character in str2
anyChar("abc", "xyz") → false
anyChar("abc", "xya") → true
anyChar("abc", "xyzxyzbxyzxyz") → true
5b)
Given a String str1 and a String str2, return true if str1 does not contains any character in str2, and false otherwise.
noChar("abc", "xyz") → true
noChar("abc", "xya") → false
noChar("xyzxyzbxyzxyz", "xyzb") → false
5c)
Given a String str1 and a String str2, return true if str1 contains every character in str2. The empty string is contained in any other String, including the empty string itself.
everyChar("abc", "xyz") → false
everyChar("abc", "xya") → false
everyChar("xyzxyzbxyzxyz", "xyzb") → true
In: Computer Science
can anyone summarize this?
Robotics and technology have always been something
that has been said will “rule the world” someday, and part of that
is true! It starts out when they begin taking jobs! One of the most
common jobs, in my eyes, that has been taken over by robotics, is
proofreading! (Bernazzani, S., N/A) In software like Google Docs
and Microsoft Word, we have the ability to tell the computer to
proofread our papers, to make sure spelling and punctuation is
correct. Another job that has been taken by robots, is a Pin
Setter, for bowling! (Jamie Harris, October, 2018) Some advantages
of robotics taking over automating production tasks, is how much
more efficiently this can be done, how much more product can be
made quicker, as well as saving money from paying employees. Some
disadvantages that this has is that the employees are left looking
for another job, and if the machinery were to ever go down, the
engineer of the robot would have to come out to replace whatever
broke, which then takes more time to replace, rather than having
another employee cover for each other if something comes
up.
I think robots will affect the society in the future
by taking over the world, literally. In McDonald’s Fast Food, there
is now a menu where you pick your order yourself, rather than
talking to a cashier at the front desk. Pretty soon, we will have
robotics that can do any and everything for us. I like to think of
it as the movie Wall-E. Yes, the robotics idea sounds great in the
beginning, but there is always the possibility that it goes too
far, and we can not do anything to fix the situation.
and feedback
In: Computer Science
a. Write short notes about smartwatch. What features a smartwatch could serve?
b. Imagine you have a friend named smith, who likes to draw and do illustrations and now he is looking to buy a device where he can do illustrations and also teach students online for tuition. What device would you suggest to your friend and why?
c. Suppose smith have a pc with intel core i7, 16 GB RAM and 500 GB HDD. But recently, he has noticed that his pc is running slow. What could be the problem? What could be the solution?
In: Computer Science
Brewster’s Used Cars, Inc. employs several salespeople. Brewster, the owner of the company, has provided a file that contains sales records for each salesperson for the past month. Each record in the file contains the following two fields:
The salesperson’s ID number, as an integer
The amount of a sale, as a real number
The records are already sorted by salesperson ID. Brewster wants you to design a program that prints a sales report. The report should show each salesperson’ssales and the total sales for that salesperson. The report should also show the total sales for all salespeople for the month. Here is an example of how the sales report should appear:
Brewster's Used Cars, Inc.
Sales Report
Salesperson ID
Sale Amount
===========================================
100
$10,000.00
100
$12,000.00
100
$5,000.00
Total sales for this salesperson: $27,000.00
101
$14,000.00
101
$18,000.00
101
$12,500.00
Total sales for this salesperson: $44,500.00
102
$13,500.00
102
$14,500.00
102
$20,000.00
Total sales for this salesperson: $48,000.00
Total of all sales: $119,500.00
I need help making a flowchart in Raptor with sub Modules.
In: Computer Science
1. Enhance Binary System Conversion program with Lab05.2 Addition Function Write a program that accepts two positive binary number in string and perform the addition with Lab05.2 function enhance in a way can accept binary string in addition to decimal string (use input parameter to control the base2 or base10 addition) and output the as binary string. (Optional: Demonstrate 8 bits and 16 bits in length as inputs.) // the example function prototype for addition function below where accepting two numbers, m, and base as input; output the addition result as string type as return value; base should be 2 or 10 as required. string addFunction(string numberA, string numberB, int m, int base); Requirement: C++ programing; program an addition algorithm function that can both accept binary and decimal addition; convert each other if necessary. ................................................................................................................................................................................................................
Requirement:
1. Write a string addFunction that both can accept two positive binary numbers and decimal numbers in string.
2. The example function prototype for addition function below where accepting two numbers,m, and base as input; output the addition result as string type as return value; base should be 2 or 10 as required.
3. Output needs as binary string.
4. Example for String addFuntion(string numberA, string number B, int m, int base).
Program language: C++
In: Computer Science