Look at the code below and use the following comments to indicate the scope of the static variables or functions. Place the comment below the relevant line.
Module scope
Class scope
Function scope
#include
2
3 static const int MAX_SIZE=10;
4
5 // Return the max value
6 static double max(double d1)
7 {
8 static double lastMax = 0;
9 lastMax = (d1 > lastMax) ? d1 : lastMax;
10 return lastMax;
11 }
12
13 // Singleton class only one instance allowed
14 class Singleton
15 {
16 public:
17 static Singleton& getSingleton() { return theOne; }
18 // Returns the Singleton
19
Answer:
Explanation:
#include
static const int MAX_SIZE=10; //Class scope
// Return the max value
static double max(double d1) //Function scope
{
static double lastMax = 0; //Function scope
lastMax = (d1 > lastMax) ? d1 : lastMax; //Function scope
return lastMax; //Module Scope
}
// Singleton class only one instance allowed
class Singleton
{
public:
static Singleton& getSingleton() //Function scope
{
return theOne; //Module Scope
}
// Returns the Singleton
Drag each statement to the correct location.
Determine if the given statements are true or false.
The hexadecimal equivalent
of 22210 is DE
The binary equivalent of
D7 is 11010011
The decimal equivalent of
1316 is 19.
True
False
Answer:
[tex](a)\ 222_{10} = DE_{16}[/tex] --- True
[tex](b)\ D7_{16} = 11010011_2[/tex] --- False
[tex](c)\ 13_{16} = 19_{10}[/tex] --- True
Explanation:
Required
Determine if the statements are true or not.
[tex](a)\ 222_{10} = DE_{16}[/tex]
To do this, we convert DE from base 16 to base 10 using product rule.
So, we have:
[tex]DE_{16} = D * 16^1 + E * 16^0[/tex]
In hexadecimal.
[tex]D =13 \\E = 14[/tex]
So, we have:
[tex]DE_{16} = 13 * 16^1 + 14 * 16^0[/tex]
[tex]DE_{16} = 222_{10}[/tex]
Hence:
(a) is true
[tex](b)\ D7_{16} = 11010011_2[/tex]
First, convert D7 to base 10 using product rule
[tex]D7_{16} = D * 16^1 + 7 * 16^0[/tex]
[tex]D = 13[/tex]
So, we have:
[tex]D7_{16} = 13 * 16^1 + 7 * 16^0[/tex]
[tex]D7_{16} = 215_{10}[/tex]
Next convert 215 to base 2, using division rule
[tex]215 / 2 = 107 R 1[/tex]
[tex]107/2 =53 R 1[/tex]
[tex]53/2 =26 R1[/tex]
[tex]26/2 = 13 R 0[/tex]
[tex]13/2 = 6 R 1[/tex]
[tex]6/2 = 3 R 0[/tex]
[tex]3/2 = 1 R 1[/tex]
[tex]1/2 = 0 R1[/tex]
Write the remainders from bottom to top.
[tex]D7_{16} = 11010111_2[/tex]
Hence (b) is false
[tex](c)\ 13_{16} = 19_{10}[/tex]
Convert 13 to base 10 using product rule
[tex]13_{16} = 1 * 16^1 + 3 * 16^0[/tex]
[tex]13_{16} = 19[/tex]
Hence; (c) is true
Write a function that takes number between 1 and 7 as a parameter and prints out the corresponding number as a string. For example, if the parameter is 1, your function should print out one. If the parameter is 2, your function should print out two, etc. If the parameter is not between 1 and 7, the function should print an appropriate error message. In your file, you should include a main() that allows the user to enter a number and calls your function to demonstrate that it works.
Answer:
The program in C++ is as follows:
#include<iostream>
using namespace std;
void changenum(int num){
string nums[7] = {"One","Two","Three","Four","Five","Six","Seven"};
if(num >7 || num < 1){
cout<<"Out of range";
}
else{
cout<<nums[num-1]; }
}
int main(){
int num;
cout<<"Number: ";
cin>>num;
changenum(num);
return 0;
}
Explanation:
The function begins here
void changenum(int num){
This initializesa string of numbers; one to seven
string nums[7] = {"One","Two","Three","Four","Five","Six","Seven"};
If the number is less than 1 or greater than 7, it prints an out of range error
if(num >7 || num < 1){
cout<<"Out of range";
}
If otherwise, the corresponding number is printed
else{
cout<<nums[num-1]; }
}
The main begins here
int main(){
This declares num as integer
int num;
Prompt the user for input
cout<<"Number: ";
Get input from the user
cin>>num;
Pass the input to the function
changenum(num);
return 0;
}
Write a C++ function for the following:
Suppose that Account class has a method called withdraw, which will be inherited by Checking and Savings class. The withdraw method will perform according to account type. So, the late bind is needed. Declare the withdraw method in Account class. The method should take a double input as withdraw amount and output true if the withdraw successfully and false if the withdraw unsuccessfully.
Solution :
class Account
[tex]$ \{ $[/tex]
public:
[tex]$\text{Account}()$[/tex];
double [tex]$\text{getBalance}$[/tex]();
void [tex]$\text{setBalance}$[/tex]();
[tex]$\text{bool withdraw}$[/tex](double bal);
[tex]$\text{private}:$[/tex]
double [tex]$\text{balance}$[/tex];
}:
[tex]$\text{Account}()$[/tex] {}
double [tex]$\text{getBalance}$[/tex]()
[tex]$ \{ $[/tex]
[tex]$\text{return balance}$[/tex];
}
void [tex]$\text{setBalance}$[/tex](double [tex]$\text{balance}$[/tex])
[tex]$ \{ $[/tex]
this.[tex]$\text{balance}$[/tex] = [tex]$\text{balance}$[/tex];
}
[tex]$\text{boolean}$[/tex] withdraw([tex]$\text{double bal}$[/tex])
[tex]$ \{ $[/tex]
if([tex]$\text{balance}$[/tex] >= bal)
[tex]$ \{ $[/tex]
[tex]$\text{balance}$[/tex] = [tex]$\text{balance}$[/tex] - bal;
[tex]$\text{return}$[/tex] true;
}
[tex]$\text{return}$[/tex] false;
}
}
Discusstheimportanceofbackingupdatainorganizations,pointingoutthebenefits
ofcloudbackupoption
Addition helps kids master the relationships between numbers and understand how quantities relate to one another. Even when kindergartners can't reliably answer addition problems or manipulate large numbers, basic addition skills give them a framework for mastering math in elementary schoo
PLEASE HURRY I WILL GIVE BRAILIEST TO WHO EVER ANSWERS AND IS CORRECT
Select all benefits of using a wiki for business.
inexpensive
accessible twenty-four hours per day and seven days per week
online conversation
quick and easy editing
document sharing
Answer:
B, D, E is the answers I think
Answer:
Accessible twenty-four hours per day and seven days per week
Quick and easy sharing
Document sharing
help asapp!!!!!! give the technical name means (write the name in one word) . the feature of virus which copies itself..
Answer:
if a computer is made out of many copies it can cause a virus with a definition of a tro Jan by a virus
Explanation:
what follows is a brief history of the computer virus and what the future holds for this once when a computer is made multiple copies of it's so several reducing malicious intent here but animal and prevade fit the definition of a Trojan buy viruses worms and Trojans paint the name Malwar as an umbrella term
One of your suppliers has recently been in the news. Workers complain of long hours, hot and stuffy workrooms, poor lighting, and even no functioning bathrooms. Some workers are less than 14 years old. Workers are paid 10 cents for each piece they complete, and fast workers are capable of finishing 50 pieces. What is the best way to describe these working conditions?
sweatshop
cottage industry
assembly line
slavery
Answer: sweatshop
Explanation
Write a Python class that inputs a polynomial in standard algebraic notation and outputs the first derivative of that polynomial. Both the inputted polynomial and its derivative should be represented as strings.
Answer:Python code: This will work for equations that have "+" symbol .If you want to change the code to work for "-" also then change the code accordingly. import re def readEquation(eq): terms = eq.s
Explanation:
You will write code to manipulate strings using pointers but without using the string handling functions in string.h. Do not include string.h in your code. You will not get any points unless you use pointers throughout both parts.
You will read in two strings from a file cp4in_1.txt at a time (there will be 2n strings, and you will read them until EOF) and then do the following. You alternately take characters from the two strings and string them together and create a new string which you will store in a new string variable. You may assume that each string is no more than 20 characters long (not including the null terminator), but can be far less. You must use pointers. You may store each string in an array, but are not allowed to treat the string as a character array in the sense that you may not have statements like c[i] = a[i], but rather *c *a is allowed. You will not get any points unless you use pointers.
Example:
Input file output file
ABCDE APBQCRDSETFG
PQRSTFG arrow abcdefghijklmnopgrstuvwxyz
acegikmoqsuwyz
bdfhjlnprtvx
Solution :
#include [tex]$< \text{stdio.h} >$[/tex]
#include [tex]$< \text{stdlib.h} >$[/tex]
int [tex]$\text{main}()$[/tex]
{
[tex]$\text{FILE}$[/tex] *fp;
[tex]$\text{fp}$[/tex]=fopen("cp4in_1.txt","r");
char ch;
//while(1)
//{
while(!feof(fp))
{
char *[tex]$\text{s1}$[/tex],*[tex]$\text{s2}$[/tex],*[tex]$\text{s3}$[/tex];
[tex]$\text{s1}$[/tex] = (char*) [tex]$\text{malloc}$[/tex]([tex]$20$[/tex] * [tex]$\text{sizeof}$[/tex](char));
[tex]$\text{s2}$[/tex] = (char*) [tex]$\text{malloc}$[/tex]([tex]$20$[/tex] * [tex]$\text{sizeof}$[/tex](char));
[tex]$\text{s3}$[/tex] = (char*) [tex]$\text{malloc}$[/tex]([tex]$40$[/tex] * [tex]$\text{sizeof}$[/tex](char));
[tex]$\text{int i}$[/tex]=0,j=0,x,y;
while(1)
{
ch=getc(fp);
if(ch=='\n')
break;
*(s1+i)=ch;
i++;
}
while(1)
{
ch=getc(fp);
if(ch=='\n')
break;
*(s2+j)=ch;
j++;
}
for(x=0;x<i;x++)
{
*(s3+x)=*(s1+x);
}
for(y=0;y<j;x++,y++)
{
*(s3+x)=*(s2+y);
}
for(x=0;x<i+j;x++)
{
printf("%c",*(s3+x));
}
printf("\n");
getc(fp);
}
}
define the term hardwar
Answer:
tools, machinery, and other durable equipment.
Explanation:hardware in a computer are the keyboard, the monitor, the mouse and the central processing unit.
Answer: tools, machinery, and other durable equipment.
Explanation: the machines, wiring, and other physical components of a computer or other electronic system.
tools, implements, and other items used in home life and activities such as gardening. Computer hardware includes the physical parts of a computer, such as the case, central processing unit, monitor, mouse, keyboard, computer data storage, graphics card, sound card, speakers and motherboard. By contrast, software is the set of instructions that can be stored and run by hardware.
The new software organization requires a new point of sale and stock control system for their many stores throughout Pakistan to replace their aging mini-based systems.
A sales assistant will be able to process an order by entering product numbers and required quantities into the system. The system will display a description, price, and available stock. In-stock products will normally be collected immediately by the customer from the store but may be selected for delivery to the customer's home address for which there will be a charge. If stock is not available, the sales assistant will be able to create a backorder for the product from a regional warehouse. The products will then either be delivered directly from the regional warehouse to the customer's home address, or the store for collection by the customer. The system will allow products to be paid for by cash or credit card. Credit card transactions will be validated via an online card transaction system. The system will produce a receipt. Order details for in-stock products will be printed in the warehouse including the bin reference, quantity, product number, and description. These will be collected by the sales assistant and given to the customer. The sales assistant will be able to make refunds, provided a valid receipt is produced. The sales assistant will also be able to check stock and pricing without creating an order and progress orders that have been created for delivery.
You need to answer the following questions. (Marks 6)
1. Which elicitation method or methods appropriate to discover the requirement for a given scenario system to work efficiently, where multiple sales and stock points manage. Justify your answer with examples.
2. Identify all stakeholders for a given scenario according to their roles and responsibilities with suitable justifications.
3. Specify functional users and systems requirements with proper justifications.
Answer:
Arid walu apna v ker luuu
Explanation:
Answer:
hn g
Explanation:
Recall the binary search algorithm.1. Using the algorithm/algorithmic environment, give pseudocode using a for loop.AnswerMy algorithm for binary search using a for loop is given in Algorithm 1.Algorithm 1BinarySearchFor(A)[[XXX TODO:pseudocode here]]2. Using the algorithm/algorithmic environment, give pseudocode using a while loop.Answer[[XXX TODO:your answer here]]3. Using the algorithm/algorithmic environment, give pseudocode using recursion.Answer[[XXX TODO:your answer here]]4. What is the loop invariant of your second algorithm
Answer:
Following are the Pseudo Code to the given question:
Explanation:
Following are the pseudo-code by using the For loop:
Defines the A function (node, element)
The node is larger than 0.
if another value of the node equals its element
Loop Break
That element if node. value becomes lower than that
Node is node equivalent.
right
Using other nodes is node equivalent.
left
Node Return
If the node is vacant
print the Tree is empty
Following are the pseudo-code by using the while loop:
Defines the function A(node,element)
While this node is not zero.
if the value of the node equals the element
Loop Break
The element if node. value is lower than
Node is node equivalent.
right
Using other nodes is equivalent to an a.left node
Node Return
If the node is vacant
print Tree is empty
following are the Pseudo-code for recursion:
Set the function A (node, key)
If no root is the same as the root or no root.
return the root.
If the root value is lower than that of the quest for key return (root. right, key)
Return your lookup (root.left,key)
Means having a current knowledge and understanding of computer mobile devices the web and related technologies
Answer:
"Digital literacy" would be the appropriate solution.
Explanation:
Capable of navigating and understanding, evaluating as well as communicating on several digital channels, is determined as a Digital literacy.Throughout the same way, as media literacy requires the capability to recognize as well as appropriately construct publicity, digital literacy encompasses even ethical including socially responsible abilities.If you want to continue working on your web page the next day, what should you do?
a. Create a copy of the file and make changes in that new copy
b. Start over from scratch with a new file
c. Once a file has been saved, you cannot change it
d. Reopen the file in your text editor to
Answer:
d. Reopen the file in your text editor
Answer:
eeeeeeeee
Explanation:
web analytics can tell you many things about your online performance, but what can analytics tools not tell you
Answer:
The answer is below
Explanation:
While web analytics such as Góogle analysts is known to help online marketers to map out a clear strategy and thereby improve their outreach, there are still some specific things the current web analytics can not do for the user. For example:
1. Web Analytics can’t accurately track leads
2. Web Analytics can’t track lead quality
3. Web Analytics can’t track the full customer journey
4. Web Analytics can’t highlight the true impact of payment.
Which statement is correct?
Flat files use foreign keys to uniquely identify tables.
Flat files use foreign keys to secure data.
A foreign key is a primary key in another table.
A foreign key uniquely identifies a record in a table.
Answer:
A foreign key is a primary key in another table.
Explanation:
Imagine that you are helping to build a store management system for a fast food restaurant. Given the following lists, write a program that asks the user for a product name. Next, find out if the restaurant sells that item and report the status to the user. Allow the user to continue to inquire about product names until they elect to quit the program.
Answer:
The program in python is as follows:
def checkstatus(food,foodlists):
if food in foodlists:
return "Available"
else:
return "Not Available"
foodlists = ["Burger","Spaghetti","Potato","Lasagna","Chicken"]
for i in range(len(foodlists)):
foodlists[i] = foodlists[i]. lower()
food = input("Food (Q to quit): ").lower()
while food != "q":
print("Status: ",checkstatus(food,foodlists))
food = input("Food (Q to quit): ").lower()
Explanation:
The program uses function.
The function is defines here. It accepts as input, a food item and a food list
def checkstatus(food,foodlists):
This check if the food is in the food lists
if food in foodlists:
Returns available, if true
return "Available"
Returns Not available, if otherwise
else:
return "Not Available"
The main begins here.
The food list is not given in the question. So, I assumed the following list
foodlists = ["Burger","Spaghetti","Potato","Lasagna","Chicken"]
This converts all items of the food list to lowercase
for i in range(len(foodlists)):
foodlists[i] = foodlists[i]. lower()
Prompt the user for food. When user inputs Q or q, the program exits
food = input("Food (Q to quit): ").lower()
This is repeated until the user quits
while food != "q":
Check and print the status of the food
print("Status: ",checkstatus(food,foodlists))
Prompt the user for another food
food = input("Food (Q to quit): ").lower()
Simon has a folder that's just a little too large for his thumb drive. How can he make the folder smaller without deleting the contents? *
Answer:
Try zipping the folder.
Explanation:
This reduces the size of the content but doesn't make you delete anything.
What is digital marketing?
Answer:
Digital marketing is the component of marketing that utilizes internet and online based digital technologies such as desktop computers, mobile phones and other digital media and platforms to promote products and services.
Explanation:
A list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor.
a. True
b. False
(The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address.A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has
Answer:
Explanation:
The following code is written in Java and creates all the classes as requested with their variables, and methods. Each extending to the Person class if needed. Due to technical difficulties I have attached the code as a txt file below, as well as a picture with the test output of calling the Staff class.
4 reasons why users attach speakers
to their computers
Answer: we connected speakers with computers for listening voices or sound because the computer has not their own speaker. the purpose of speakers is to produce audio output that can be heard by the listener. Speakers are transducers that convert electromagnetic waves into sound waves. The speakers receive audio input from a device such as a computer or an audio receiver.
Explanation: Hope this helps!
You are responsible for a rail convoy of goods consisting of several boxcars. You start the train and after a few minutes you realize that some boxcars are overloaded and weigh too heavily on the rails while others are dangerously light. So you decide to stop the train and spread the weight more evenly so that all the boxcars have exactly the same weight (without changing the total weight). For that you write a program which helps you in the distribution of the weight.
Your program should first read the number of cars to be weighed (integer) followed by the weights of the cars (doubles). Then your program should calculate and display how much weight to add or subtract from each car such that every car has the same weight. The total weight of all of the cars should not change. These additions and subtractions of weights should be displayed with one decimal place. You may assume that there are no more than 50 boxcars.
Example 1
In this example, there are 5 boxcars with different weights summing to 110.0. The ouput shows that we are modifying all the boxcars so that they each carry a weight of 22.0 (which makes a total of 110.0 for the entire train). So we remove 18.0 for the first boxcar, we add 10.0 for the second, we add 2.0 for the third, etc.
Input
5
40.0
12.0
20.0
5. 33.
0
Output
- 18.0
10.0
2.0
17.0
-11.0
Answer:
The program in C++ is as follows:
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int cars;
cin>>cars;
double weights[cars];
double total = 0;
for(int i = 0; i<cars;i++){
cin>>weights[i];
total+=weights[i]; }
double avg = total/cars;
for(int i = 0; i<cars;i++){
cout<<fixed<<setprecision(1)<<avg-weights[i]<<endl; }
return 0;
}
Explanation:
This declares the number of cars as integers
int cars;
This gets input for the number of cars
cin>>cars;
This declares the weight of the cars as an array of double datatype
double weights[cars];
This initializes the total weights to 0
double total = 0;
This iterates through the number of cars
for(int i = 0; i<cars;i++){
This gets input for each weight
cin>>weights[i];
This adds up the total weight
total+=weights[i]; }
This calculates the average weights
double avg = total/cars;
This iterates through the number of cars
for(int i = 0; i<cars;i++){
This prints how much weight to be added or subtracted
cout<<fixed<<setprecision(1)<<avg-weights[i]<<endl; }
In Word, when you conduct a merge a customized letter, envelope, label is created for each record in the data source. True or False.
What is the meaning of integreted progam and it examples
Answer:
Integrated software is a collection of software designed to work similar programs. A good example of integrated software package is Microsoft Office, which contains programs used in an office environment (Excel, Outlook, and Word).
Define a class Complex to represent complex numbers. All complex numbers are of the form x + yi, where x and y are real numbers, real numbers being all those numbers which are positive, negative, or zero.
Answer:
The program in C++ is as follows:
#include<bits/stdc++.h>
using namespace std;
class Complex {
public:
int rl, im;
Complex(){ }
Complex(int Real, int Imaginary){
rl = Real; im = Imaginary;
}
};
int main(){
int real, imag;
cout<<"Real: "; cin>>real;
cout<<"Imaginary: "; cin>>imag;
Complex ComplexNum(real, imag);
cout<<"Result : "<< ComplexNum.rl<<" + "<<ComplexNum.im<<"i"<<endl;
}
Explanation:
See attachment for explanation
Write a c++ to read seven days in an array and print it
Explanation:
Photosynthesis, the process by which green plants and certain other organisms transform light energy into chemical energy. During photosynthesis in green plants, light energy is captured and used to convert water, carbon dioxide, and minerals into oxygen and energy-rich organic compounds.
Ling has configured a delegate for her calendar and would like to ensure that the delegate is aware of their permissions. Which option should she configure?
Delegate can see my private Items
Tasks > Editor
Inbox > None
Automatically send a message to delegate summarizing these permissions
Answer:
Tasks>Editor (B)
Explanation:
I just did the test
Answer:
Tasks > Editor
Explanation:
Did the test
What is output? public class MathRecursive { public static void myMathFunction(int a, int r, int counter) { int val; val = a*r; System.out.print(val+" "); if (counter > 4) { System.out.print("End"); } else { myMathFunction(val, r, counter + 1); } } public static void main (String [] args) { int mainNum1 = 1; int mainNum2 = 2; int ctr = 0; myMathFunction(mainNum1, mainNum2, ctr); } }
a) 2 4 8 16 32 End
b) 2 2 2 2 2
c) 2 4 8 16 32 64 End
d) 2 4 8 16 32
Answer:
The output of the program is:
2 4 8 16 32 64 End
Explanation:
See attachment for proper presentation of the program
The program uses recursion to determine its operations and outputs.
The function is defined as: myMathFunction(int a, int r, int counter)
It initially gets the following as its input from the main method
a= 1; r = 2; counter = 0
Its operation goes thus:
val = a*r; 1 * 2 = 2
Print val; Prints 2
if (counter > 4) { System.out.print("End"); } : Not true
else { myMathFunction(val, r, counter + 1); }: True
The value of counter is incremented by 1 and the function gets the following values:
a= 2; r = 2; counter = 1
val = a*r; 2 * 2 = 4
Print val; Prints 4
else { myMathFunction(val, r, counter + 1); }: True
The value of counter is incremented by 1 and the function gets the following values:
a= 4; r = 2; counter = 2
val = a*r; 4 * 2 = 8
Print val; Prints 8
else { myMathFunction(val, r, counter + 1); }: True
The value of counter is incremented by 1 and the function gets the following values:
a= 8; r = 2; counter = 3
val = a*r; 8 * 2 = 16
Print val; Prints 16
else { myMathFunction(val, r, counter + 1); }: True
The value of counter is incremented by 1 and the function gets the following values:
a= 16; r = 2; counter = 4
val = a*r; 16 * 2 = 32
Print val; Prints 32
else { myMathFunction(val, r, counter + 1); }: True
The value of counter is incremented by 1 and the function gets the following values:
a= 32; r = 2; counter = 5
val = a*r; 32 * 2 = 64
Print val; Prints 64
if (counter > 4) { System.out.print("End"); } : True
This prints "End"
So; the output of the program is:
2 4 8 16 32 64 End