Answer:
doon sa pasay nag kakapi
As you will solve more complex problems, you will find that searching for values in arrays becomes a crucial operation. In this part of the lab, you will input an array from the user, along with a value to search for. Your job is to write a C++ program that will look for the value, using the linear (sequential) search algorithm. In addition, you should show how many steps it took to find (or not find) the value, and indicate whether this was a best or worst case scenario (... remember the lecture). You may refer to the pseudo-code in the lecture, but remember that the details of the output and error conditions are not specified there. Also, note that in pseudo-code arrays are sometimes defined with indices 1 to N, whereas in C++ the indexes span from 0 to N-1.
The program will work as follows. First, you should ask the user to enter the size of the array, by outputting:
"Enter the size of the array: "
to the console. If the user enters an incorrect size, you should output the error message:
"ERROR: you entered an incorrect value for the array size!"
and exit the program. If the input is a valid size for the array, ask the user to enter the data, by outputting
"Enter the numbers in the array, separated by a space, and press enter: "
Let the user enter the numbers of the array and store them into a C++ array. Up to now, this should be exactly the same code as Lab#2. Next, ask the user a value v to search for in the array (called the "key"), by outputting:
"Enter a number to search for in the array: " to the screen, and read the key v.
Search for v by using the linear search algorithm. If your program finds the key, you should output:
"Found value v at index i, which took x checks. "
where i is the index of the array where v is found, and x is the number of search operations taken place.
If you doesn't find the key, then output: "
The value v was not found in the array!"
Then indicate whether you happened to run into a best or worst case scenario. In case you did, output: "
We ran into the best case scenario!" or "We ran into the worst case scenario!"
otherwise, don't output anything.
Answer:
#include<iostream>
using namespace std;
int main() {
cout<<"Enter The Size Of Array: ";
int size;
bool isBestCase=false;
cin>>size;
if(size<=0){
cout<<"Error: You entered an incorrect value of the array size!"<<endl;
return(0);
}
int array[size], key;
cout<<"Enter the numbers in the array, separated by a space, and press enter:";
// Taking Input In Array
for(int j=0;j<size;j++){
cin>>array[j];
}
//Your Entered Array Is
for(int a=0;a<size;a++){
cout<<"array[ "<<a<<" ] = ";
cout<<array[a]<<endl;
}
cout<<"Enter a number to search for in the array:";
cin>>key;
for(i=0;i<size;i++){
if(key==array[i]){
if(i==0){
isBestCase=true; // best case scenario when key found in 1st iteration
break;
}
}
}
if(i != size){
cout<<"Found value "<<key<<" at index "<<i<<", which took " <<++i<<" checks."<<endl;
} else{
cout<<"The value "<<key<<" was not found in array!"<<endl;
cout<<"We ran into the worst-case scenario!"; // worst-case scenario when key not found
}
if(isBestCase){
cout<<"We ran into the best case scenario!";
}
return 0;
}
Explanation:
The C++ source dynamically generates an array by prompting the user for the size of the array and fills the array with inputs from the user. A search term is used to determine the best and worst-case scenario of the created array and the index and search time is displayed.
5. Select the correct answer.
Henry uploaded the photos of his birthday to a cloud storage system. He feels that it’s a safe option for data storage. His friend suggested that there may be a disadvantage to cloud storage. Which disadvantage is Henry’s friend referring to?
A.
The owner may not be able to delete the data after the upload.
B.
The file format of the images may be corrupted.
C.
The service can sell the data without notifying the owner.
D.
People can alter the data without notifying the owner.
E.
The data is not under the owner’s direct control.
Answer: E. The data is not under the owner’s direct control.
Explanation:
A massive disadvantage to cloud storage is that the data stored is ot under the direct control of the person uploading. They first have to access the service and that service is owned by the company offering the cloud storage.
If for any reason the company decides not to give access (depending on local laws), or if the company suffers a problem that affects its ability to offer the service, the person who uploaded could lose access to their data.
true or false. in a list with 5 items the index of the final item is 4
Answer: True
Explanation:
We start at 0 for lists
[item, item, item, item, item]
0 1 2 3 4
true on edge2020/2021
A mobile base station in an urban environment has a power measurement of 25 µW at 225 m. If the propagation follows an inverse 4th-power law, assuming a distance of 0.9 km from the base station, what would be a reasonable power value, in µW?
Give your answer in scientific notation to 2 decimal places
Answer:
The answer is below
Explanation:
The inverse fourth power law states that the intensity varies inversely to the fourth power of the distance from the source. That is as the distance increases, the intensity decreases.
Let I represent the intensity and let d represent the distance from the source, hence:
I ∝ 1 / d⁴
I = k / d⁴
Where k is the constant of proportionality.
Given that at a power of 25W = 25*10⁻⁶ W, the distance (d) = 225 m. We can find the value of k.
25*10⁻⁶ = k / 225⁴
k = 225⁴ * 25*10⁻⁶ = 64072.27
Hence:
I = 64072.27 / d⁴
At a distance (d) = 0.9km = 900 m, we can find the corresponding power:
I = 64072.27 / 900⁴
I = 9.77 * 10⁻⁸ W
1. Select two forms of case designed suitable for ATX power supply and
motherboard,
A. Chassis and cabinet
B. Cabinet and tower
C. Desktop and tower
D. Chassis and tower
A common programming operation is to swap or exchange the values of two variables. If the value of x is currently 19 and the value of y is 42, swapping them will make x into 42 and y into 19. Write a program named Swap.java that allows the user to enter two int values. The program should store those values into variables and then swap the variables. Print the values of both variables before and after the swap. You will receive full credit as long as your solution works, but try to do this using as few variables as possible
Answer:
import java.util.Scanner;
public class Swap
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int x, y, t;
System.out.print("Enter the first variable: ");
x = input.nextInt();
System.out.print("Enter the second variable: ");
y = input.nextInt();
System.out.printf("Values before the swap -> x = %d, y = %d\n", x, y);
t = x;
x = y;
y = t;
System.out.printf("Values after the swap -> x = %d, y = %d\n", x, y);
}
}
Explanation:
Import the Scanner class
Create a Scanner object to be able to get input from the user
Declare the variables, x, y, and t - the variable t will be used as temporary variable that will hold the value of x
Ask the user to enter the first and second variables
Print the values before swap
Assign the value of x to the t
Assign the value of y to the x (Now, x will have the value of y)
Assign the value of the t to the y (Since t holds the value of x, y will have the value of x)
Print the values after the swap
Using words input, output, processor, CPU, memory, RAM, ROM, and storage,
answer the questions:
Copy and paste your answers to avoid misspelling.
1. A computer processor is also called CPU
2. A speaker is a(n)
device.
3. A scanner is an
device.
4. Hard disk is a(n)
device.
5. RAM and ROM are types of
Mmory
6. A computer monitor is a output
I
device.
here because brainly sucks I hate this website stop censoring litteraly everything, can't get away with calling someone a poopy head on here
The more employees can do, the less they have to be managed by supervisors.
Please select the best answer from the choices provided
T
F
Answer:
True
Explanation:
What does Ares want Percy to do for him?
Answer:
Get his sheild
Explanation:
Answer:
Ares wants Percy to retrieve his shield
Explanation:
Write a C# program named ProjectedRaises that includes a named constant representing next year’s anticipated 4 percent raise for each employee in a company. Also declare variables to represent the current salaries for three employees. Assign values to the variables, and display, with explanatory text, next year’s salary for each employee. Note: For final submission assign the following current salaries for the employees: 25000 for employee 1, 38000 for employee 2, 51000 for employee 3. Then next year's salary for employee 1 would be displayed as: Next year's salary for the first employee will be $26,000.00
Answer:
using System;
class ProjectedRaises {
static void Main() {
const float raise = 0.04f;
double salary1 = 0.0f,salary2 = 0.0f,salary3 = 0.0f;
Console.WriteLine("Current salary for each employee: ");
salary1 = Single.Parse(Console.ReadLine());
salary2 = Single.Parse(Console.ReadLine());
salary3 = Single.Parse(Console.ReadLine());
salary1 = salary1 + raise * salary1;
salary2 = salary2 + raise * salary2;
salary3 = salary3 + raise * salary3;
Console.WriteLine("Next year salary for the employees are: ");
Console.WriteLine(Math.Round(salary1));
Console.WriteLine(Math.Round(salary2));
Console.WriteLine(Math.Round(salary3));
}
}
Explanation:
This declares and initializes variable raise as a float constant
const float raise = 0.04f;
This declares the salary of each employee as double
double salary1 = 0.0f,salary2 = 0.0f,salary3 = 0.0f;
This prompts the user for the salaries of the employee
Console.WriteLine("Current salary for each employee: ");
The next three lines get the salary of the employees
salary1 = Single.Parse(Console.ReadLine());
salary2 = Single.Parse(Console.ReadLine());
salary3 = Single.Parse(Console.ReadLine());
The next three lines calculate the new salaries of the employees
salary1 = salary1 + raise * salary1;
salary2 = salary2 + raise * salary2;
salary3 = salary3 + raise * salary3;
This prints the header
Console.WriteLine("Next year salary for the employees are: ");
The next three lines print the new salaries of the employees
Console.WriteLine(Math.Round(salary1));
Console.WriteLine(Math.Round(salary2));
Console.WriteLine(Math.Round(salary3));
Select each of the benefits of wireless communication.
checking e-mail from a remote location
o transmiting broadcast signals
receiving voicemail messages while away from the office
sending and receiving graphics and video to coworkers
sending data from outside the office
Answer:
checking e-mail from a remote location
receiving voicemail messages while away from the office
sending and receiving graphics and video to coworkers
sending data from outside the office
Explanation:
Wireless networks have proved to be more beneficial and accessible as compared to the wired networks. Wireless networks have helped in increasing the efficiency of transferring the data. It is also very accessible and easy to operate. It helps a person be connected even during travelling. It saves the cost and helps in better execution of the work. The speed at which the data is transferred helps in saving the cost and time. The maintenance cost is reduced in wireless communication as that of wired one. It also helps during the times of emergency situations.
Answer:
checking e-mail from a remote location
receiving voicemail messages while away from the office
sending and receiving graphics and video to coworkers
sending data from outside the office
Explanation:
EDGE 2021
1, 3,4,5
(3)(6 Points) During a sale at a store, a 10% discount is applied to purchases over $10.00. Write a program that asks for the amount of a purchase, then calculates the discounted price. The purchase amount will be input in cents (as an integer). These are two examples of your expected program's execution.
Austin has a report due at school tomorrow, but has not started working on it yet. Now he is worried about getting a bad grade. So he searches the Internet for his topic and finds lots of information. He chooses a small, obscure site, copies text and images, and pastes them into his report. He's done before bedtime. But he receives an F on his report.
1. What could Sam have done differently on his report to avoid failing?
2. Is this incident an example of an unethical action or an illegal action?
Answer:
Explanation:
Question One
He could have read other sites with other points of view and summarized that. Most importantly he could have used footnotes that gave credit to every idea that he used.
He could have put the material down and begin to write. The words would have come out in his awkward style. He would still need to footnote the ideas. That is most important.
Question Two
It is both. Plagiarism is a serious crime if it involves many people being affected by what he wrote.
But it is totally unethical at any level. Trying to pass off something that isn't yours is totally unethical. It should never be done. It shames the subject which is shown to be unimportant and it shames the instructor (he knew enough to catch the plagiarism), and it shames the person getting caught.
Which command will provide us with a list of the available internal commands (commands that are part of Command Prompt, such as CD and DIR - not IPCONFIG or NETSTAT) of Command Prompt?
Answer: $help
Explanation:
Not sure which terminal you are using, but "help" in the terminal outputs available internal commands.
What is the total March Expenditure now? (cell Q2)
Complete the sentence.
If you wanted the best performance for a game that requires a powerful graphics processor and lots of memory, you
would run it on a
tablet
desktop
smartphone
write an algorithm and draw a flowchart to calculate the sum of of the first 10 natural numbers starting from 1
Answer:
#include <stdio.h>
void main()
{
int j, sum = 0;
printf("The first 10 natural number is :\n");
for (j = 1; j <= 10; j++)
{
sum = sum + j;
printf("%d ",j);
}
printf("\nThe Sum is : %d\n", sum);
}
Within a loop
Step 1: Initialize a variable to 1 (say x=1)
Step 2: Specifiy the condition
In this case x<=10
Step 3: Increment the variable by 1
using increment operator x++
OR
simply x+=1(x=x+1)
Step 4: Print the value of variable
Terminate the loop
Explanation:
Write a piece of codes that asks the user to enter a month (an integer), a day (another integer), and a two-digit year. The program should then determine whether the month times the day is equal to the year. If so, it should display a message saying the date is magic. Otherwise, it should display a message saying the date is not magic.
#include
using namespace std;
int main()
{
int day;
int month;
int year;
cout<<"enter year"<
cin>>year;
cout<<"enter day"<
cin>>day;
cout<<"enter month"<
cin>>month;
//programology..
if(month*day==year)
{
cout<<"its magic programology year"<
}
else
{
cout<<"its not magic year"<
}
}
Answer:
Follows are the code to this question:
#include <iostream>//header file
using namespace std;
int main()//main method
{
int day,month,year;//defining integer variable
cout<<"please enter last two digit of the year: "; //print message
cin>>year;//input year value
cout<<"enter day: "; //print message
cin>>day;//input day value
cout<<"enter month: ";//print message
cin>>month;//print month message
if(month*day==year)//check magic date condition
{
cout<<"its magic programology year";//print message
}
else
{
cout<<"its not magic year";//print message
}
return 0;
}
Output:
please enter last two digit of the year: 98
enter day: 14
enter month: 7
its magic programology year
Explanation:
In the given code, three integer variable "day, month, and year" is declared, that uses the input method "cin" to input the value from the user-end.
In the next step, an if block statement is used that check month and day value multiple is equal to year value, if the condition is true it will print "magic programology year" otherwise it will print "not the magic year".
Nearly all personal computers are capable of serving as network servers.
Question 26 options:
True
False
7.4 question 1 edhesive
Answer:
huh
Explanation:
what do you mean? the question doesn't make any sense
Answer:
def GPAcalc(g):
if g == "a" or g == "A":
return 4
elif g == "B" or g == "b":
return 3
elif g == "C" or g == "c":
return 2
elif g == "D" or g == "d":
return 1
elif g == "F" or g == "f":
return 0
else:
return "Invalid"
grade = input("Enter your Letter Grade: ")
gpa = GPAcalc(grade)
print("Your GPA score is: " + str(gpa))
Explanation:
Despite all of the trouble that Percy and his friends are encountering, why do you think he continues on his quest? What does that say about his character?
Answer:
To be like his dad maybe I don't a 100%
(Python)
Summary: Given integer values for red, green, and blue, subtract the gray from each value.
Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray).
Given values for red, green, and blue, remove the gray part.
Ex: If the input is:
130
50
130
the output is:
80 0 80
Find the smallest value, and then subtract it from all three values, thus removing the gray.
r=int(input("Enter the red value: "))
g=int(input("Enter the green value: "))
b=int(input("Enter the blue value: "))
m=min([r,g,b])
print(str(r-m)+" "+str(g-m)+" "+str(b-m))
I wrote my code in python 3.8. I hope this helps
What is user interface
Answer:
a user interface is the thing that apears after the login
Explanation:
go to goolge and type microsoft flight simulator user intr=erface
5. Played electronically by manipulating images on a television screen produced by a
computer program often emphasizing fast action
mi Yoko
tor of the "GAME BOY" and "Game and Watch hand held systems
Answer:
1) Video Games
2) Gunpei Yokoi
Explanation:
1) Video games are electronic games played off electronic consoles which are connected to Visual Display Units such as desktops or laptops and flat=screen televisions. The games are created in such a way that images can be manipulated using a pad and controlled by the computer program.
2) Gunpei Yokoi person who made the "game boy" and "game and watch" hand-held games.
He was recognized posthumously for his achievements in 2003 when he was offered a lifetime achievement award from the international game developers association.
Cheers
Create a Python program that computes the cost of carpeting a room. Your program should prompt the user for the width and length in feet of the room and the quality of carpet to be used. A choice between three grades of carpet should be given. You should decide on the price per square foot of the three grades on carpet. Your program must include a function that accepts the length, width, and carpet quality as parameters and returns the cost of carpeting that room. After calling that function, your program should then output the carpeting cost. of carpeting a room. Note: the output is NOT in the function but in the main. Display your name,class,date as per SubmissionRequirements by using a function.
Your program should include your design steps as your comments. Document the values you chose for the prices per square foot of the three grades of carpet in your comments as well.
Answer:
In Python:
def calcCost(length,width,quality):
if quality == 1:
cost = length * width * 3.50
if quality == 2:
cost = length * width * 2.50
else:
cost = length * width * 1.50
return cost
length = float(input("Room Length: "))
width = float(input("Room Width: "))
print("Quality:\n1 - Best\n2 - Moderate\n3 and others - Worst")
quality = int(input("Quality: "))
print("Calculate: "+str(calcCost(length,width,quality)))
Explanation:
This defines the function calcCost to calculate the carpeting cost
def calcCost(length,width,quality):
If quality is 1, the total cost is calculated by area * 3.50
if quality == 1:
cost = length * width * 3.50
If quality is 2, the total cost is calculated by area * 2.50
if quality == 2:
cost = length * width * 2.50
For other values of quality, the total cost is calculated by area * 1.50
else:
cost = length * width * 1.50
This returns the calculated carpeting cost
return cost
The main begins here
This prompts the user for the length of the room
length = float(input("Room Length: "))
This prompts the user for the width of the room
width = float(input("Room Width: "))
This gives instruction on how to select quality
print("Quality:\n1 - Best\n2 - Moderate\n3 and others - Worst")
This prompts the user for the quality of the carpet
quality = int(input("Quality: "))
This calls the calcCost method and also printst the calculated carpeting cost
print("Calculate: "+str(calcCost(length,width,quality)))
Write a program in your favorite language (e.g., C, Java, C , etc.) to convert max. 32 bit numbers from binary to decimal. The user should type in an unsigned binary number. The program should print the decimal equivalent. You should write a program from scratch that performs the conversion, please do not use built in functions. Please provide a screenshot of your program running on these values: 111011012 110000110011110101110101011101012 Please also include your source code together with your answers to assignment questions.
Answer:
In Python:
bin = int(input("Binary Number: "))
num = str(bin)
dec = 0
for i in range(len(num)):
dec = dec + int(num[i]) * 2**int(len(num)-i-1)
print("Decimal Equivalent: "+str(dec))
Explanation:
Note that the program assumes that the user input will be valid. So, error check was done in the program
This line gets the binary number from the user
bin = int(input("Binary Number: "))
This converts the inputted number to string
num = str(bin)
This initializes decimal number to 0
dec = 0
This iterates through the string number
for i in range(len(num)):
This converts the number to decimal
dec = dec + int(num[i]) * 2**int(len(num)-i-1)
This prints the result of the conversion
print("Decimal Equivalent: "+str(dec))
See attachment for screenshots
import java.util.ArrayList;
import java.util.List;
/**
* Fix the problem in the following code by changing the Point class only,
* without touching the code in main(). Make only the necessary changes.
*/
public class PointTest {
static final class Point {
private double x, y;
List points = new ArrayList<>();
Point(double x, double y) {
this.x = x;
this.y = y;
}
}
public static void main(final String[] args) {
List pointList = new ArrayList<>();
pointList.add(new Point(1, 2));
pointList.add(new Point(3, 4));
System.out.println(pointList.size());
// remove the second Point
pointList.remove(new Point(3, 4));
System.out.println(pointList.size());
// Not removed!
}
}
Answer:
Explanation:
The following code was fixed but it is impossible to fix the entirety of the code without adjusting the Main method as well. This is because the information is being saved in an ArrayList that is saved within the main method. This means that either we need to move the Arraylist outside of the main method or adjust something inside the main method as well to make the code run. In this iteration, I have added an IF statement to the Point method so that it deletes a point if it is being added for a second time. In order to accomplish this, I had to add an extra argument when calling the Point Method in the Main method which would be the ArrayList in which the information is saved.
import java.util.ArrayList;
import java.util.List;
class PointTest {
static final class Point {
private double x, y;
Point(double x, double y, List<Point> points) {
this.x = x;
this.y = y;
for (int i = 0; i < points.size(); i = i+1) {
if ((points.get(i).x == x) && (points.get(i).y == y)) {
points.remove(i);
}
}
}
}
public static void main(final String[] args) {
List<Point> pointList = new ArrayList<>();
pointList.add(new Point(1, 2, pointList));
pointList.add(new Point(3, 4, pointList));
System.out.println(pointList.size());
// remove the second Point
pointList.remove(new Point(3, 4, pointList));
System.out.println(pointList.size());
// REMOVED!!!!!
}
}
Question 4 (5 points)
The more RAM you have, the less things your computer can do at the same time.
True
False
ent:
what do mean by cpu? example
Explanation:
The main computer case containing the central components of a personal computer is CPU.
The central processing unit (CPU) can be defined as the brain of the computer, it also takes the raw data and turns it into information.
Malcolm Movers charges a base rate of $200 per move plus $150 per hour and $2 per mile. Write a program named MoveEstimator that prompts a user for and accepts estimates for the number of hours for a job and the number of miles involved in the move and displays the total moving fee. For example, if 25 hours and 55 miles are input the output would be displayed as: For a move taking 25 hours and going 55 miles the estimate is $4,060.00
Answer:
import java.util.Scanner;
public class MoveEstimator
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
final int BASE_RATE = 200, RATE_PER_HOUR = 150, RATE_PER_MILE = 2;
int hours, miles;
double totalFee = 0.0;
System.out.print("Enter the number of hours for a job: ");
hours = input.nextInt();
System.out.print("Enter the number of miles: ");
miles = input.nextInt();
totalFee = BASE_RATE + (hours * RATE_PER_HOUR) + (miles * RATE_PER_MILE);
System.out.printf("For a move taking %d hours and going %d miles the estimate is $%.2f", hours, miles, totalFee);
}
}
Explanation:
*The code is in Java.
Create the Scanner object to be able to get input
Initialize the constant values using final keyword, BASE_RATE, RATE_PER_HOUR, RATE_PER_MILE
Declare the variables, hours, miles, totalFee
Ask the user to enter the hours and miles
Calculate the totalFee, add BASE_RATE, multiplication of hours and RATE_PER_HOUR, multiplication of miles and RATE_PER_MILE
Print the output as in required format
The program named MoveEstimator that prompts a user for and accepts estimates for the number of hours for a job and the number of miles involved in the move and displays the total moving fee is as follows:
x = int(input("number of hours for the job "))
y = int(input("number of miles involved "))
def MoveEstimator(x, y):
return 200 + 150*x + 2*y
print(MoveEstimator(x, y))
Code explanation:The first line of code used the variable, x to store the input of the hours for the jobThe second line of code is used to store the input of the number of miles travelled. Then, we define a function that accept the users inputs(argument) as variable x and y. Then return the mathematical operation to find the total moving fee.Finally, we call the function with a print statement.learn more on python code here: https://brainly.com/question/22841107