Using the knowledge in computational language in C++ it is possible to write a code that complete main() to read dates from input, one date per line
Writting the code:#include <iostream>
#include <string>
using namespace std;
int DateParser(string month) {
int monthInt = 0;
if (month == "January")
monthInt = 1;
else if (month == "February")
monthInt = 2;
else if (month == "March")
monthInt = 3;
else if (month == "April")
monthInt = 4;
else if (month == "May")
monthInt = 5;
else if (month == "June")
monthInt = 6;
else if (month == "July")
monthInt = 7;
else if (month == "August")
monthInt = 8;
else if (month == "September")
monthInt = 9;
else if (month == "October")
monthInt = 10;
else if (month == "November")
monthInt = 11;
else if (month == "December")
monthInt = 12;
return monthInt;
}
int main ()
{
// TODO: Read dates from input, parse the dates to find the one
// in the correct format, and output in m/d/yyyy format
while(1)
{
//declaring the required variables
int monthInt,dayInt,yearInt;string input;
//receive the input string frim the user
getline(cin,input);
//if the input is -1 then quit
if(input=="-1")
break;
//else try to process the input
try
{
//find and extract the month name and parse it to monthInt
monthInt=DateParser(input.substr(0,input.find(' ')));
//find and extract the day and parse it to dayInt
dayInt=stoi(input.substr(input.find(' '),input.find(", ")));
//find and extract the year and parse it to yearInt
yearInt=stoi(input.substr(input.find(", ")+1,input.length()));
//display the output
cout<<monthInt<<"/"<<dayInt<<"/"<<yearInt<<endl;
}
//catch if any of the exceptions happens
catch(exception& e){}
}
}
See more about C++ at brainly.com/question/19705654
#SPJ1
A small publishing company that you work for would like to develop a database that keeps track of the contracts that authors and publishers sign before starting a book. What fields do you anticipate needing for this database
Answer:
The database can include the fields related to the Author such as name and address, related to Publisher such as publisher's name and address, related to book such as title and ISBN of the book and related to contract such as payment schedule, contract start and end.
Explanation:
The following fields can be needed for this database:
Author First_NameAuthor's Last_NameAuthors_addressPublisher_namePublisher_addressBook_titleBook ISBNcontract date : this can be start_date (for starting of contract) and end_date ( when the contract ends) payment_made: for payment schedule.You are a network technician for a small corporate network that supports 1000 Mbps (Gigabit) Ethernet. The manager in the Executive Office says that his network connection has gone down frequently over the past few days. He replaced his Ethernet cable, but the connection problem has continued. Now his network connection is either down or very slow at all times. He wants you to install a new 1000 Mbps Ethernet network card in his workstation to see if that solves the problem.
If the new card does not resolve the issue, you will need to perform troubleshooting tasks to find the cause of the issue and confirm that the problem is fixed after you implement a solution. Following are some troubleshooting tasks you can try:
• Use the Network and Sharing Center and the ipconfig command on the Exec workstation to check for a network connection or an IP address.
• Look at the adapter settings to see the status of the Ethernet connection.
• Use the ping command to see if the workstation can communicate with the server in the Networking Closet. (See the exhibit for the IP address.)
• View the network activity lights for all networking devices to check for dead connections. In this lab, your task is to complete the following:
1. Install a new Ethernet adapter in one of the open slots in the Exec workstation per the manager's request.
2. Make sure that the new adapter is connected to the wall outlet with a cable that supports Gigabit Ethernet.
3. Resolve any other issues you find using the known good spare components on the Shelf to fix the problem and restore the manager's internet connection.
After you replace the network adapter and resolve the issues you found while troubleshooting, use the Network and Sharing Center to confirm that the workstation is connected to the network and the internet
If necessary, click Exhibits to see the network diagram and network wiring schematics.
Answer:
The step by step explanation
Explanation:
Before doing anything, the first thing to do is to select the 100BaseTX network adapter and reconnect the Cat5e cable. The 100BaseTX network adapter supports Fast
Ethernet which is all that is required.
Now do the following steps:
Step one
In Office 2, switch to the motherboard view of the computer (turning off the workstation as necessary).
Step two
On the Shelf, expand the Network Adapters category.
Step three
Identify the network adapter that supports Fast Ethernet 100BaseTX. Drag the network adapter from the Shelf to a
free PCI slot on the computer.
Step four
To connect the computer to the network, switch to the back view of the computer.
Step five
Drag the Cat5 cable connector from the motherboard's NIC to the port of the 100BaseTX network adapter.
Step six
To verify the connection to the local network and the Internet, switch to the front view of the computer.
Step seven
Click the power button on the computer case.
Step eight
After the workstation's operating system is loaded, click the networking icon in the notification area and click
Open Network and Sharing Center. The diagram should indicate an active connection to the network and the
Internet.
For one to be able to confirm the speed of the connection, it can be done by clicking the Local Area Connection link in the Network and
Sharing Center.
Consider the following concurrent tasks, in which each assignment statement executes atomically. Within a task, the statements occur in order. Initially, the shared variables x and y are set to 0.
Task 1 Task 2
x = 1 y = 1
a = y b = x
At the end of the concurrent tasks, the values ofa andb are examined. Which of the following must be true?
I. ( a == 0 ) ( b == 1 )
II. ( b == 0 ) ( a == 1 )
III. ( a == 1 ) ( b == 1 )
(A) I only
(B) II only
(C) III only
(D) I and II only
(E) I, II, and III
Answer:
(D) I and II only
Explanation:
Concurrent tasks is when there is more than one task to be performed but the order of the task is not determined. The tasks occur asynchronously which means multiple processors occur execute input instruction simultaneously. When x =1 and y = 1, the concurrent task will be performed and the a will be zero or either 1.
Universal Containers (UC) is currently live with Sales Cloud and in the process of implementing Service Cloud. UC wants to create a sandbox to test its Service Cloud implementation with real Sales Cloud data. Which three Sandbox types can be used to accomplish this? Choose 3 answersA. Administrator SandboxB. Partial Copy SandboxC. Full SandboxD. Developer k Pro SandboxE. Test Sandbox
Answer:
B. Partial Copy Sandbox
C. Full Sandbox
D. Developer k Pro Sandbox
Explanation:
In this scenario Universal containers wants to implement a service cloud and test with real Sales Cloud data.
Service cloud is defined a system that allows automation of various customer service functions. It can listen to customers via different social media platforms and direct customers to agents that can solve their problems.
Sandbox is a testing environment that is isolated and allows for running of programs without affecting the application.
To test service cloud implementation with real data we use the following 3 sandboxes:
- Partial copy sandbox: copies only relevant data to test configurations with real data.
- Full Sandbox: makes a replica of data by copying all data such as attachments, metadata, and object records.
- Developer K pro sandbox: is used by developers to test software in an isolated environment and can use large data sets. It includes configuration data (metadata)
Larry sees someone he finds annoying walking toward him. Larry purposely looks away and tries to engage in conversation with someone else. Which type of eye behavior is Larry using?
a. mutual lookingb. one-sided lookingc. gaze aversiond. civil inattentione. staring
Answer:
one-sided looking
Explanation:
Larry purposely looks away
import java.util.Scanner; public class ArraySum { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); final int NUM_ELEMENTS = 8; // Number of elements int[] userVals = new int[NUM_ELEMENTS]; // User numbers int i = 0; // Loop index int sumVal = 0; // For computing sum // Prompt user to populate array System.out.println("Enter " + NUM_ELEMENTS + " integer values..."); for (i = 0; i < NUM_ELEMENTS; ++i) { System.out.print("Value: "); userVals[i] = scnr.nextInt(); } // Determine sum sumVal = 0; for (i = 0; i < NUM_ELEMENTS; ++i) { sumVal = sumVal + userVals[i]; } System.out.println("Sum: " + sumVal); return; } }
Answer:
There's nothing wrong with the question you posted except that it's not well presented or arranged.
When properly formatted, the program will be error free and it'll run properly.
The programming language used in the question is Java programming lamguage.
in java, the sign ";" signifies the end of each line and lines that begins with // represent comments. Using this understanding of end of lines and comments, the formatted code goes thus
import java.util.Scanner;
public class Arraysum {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
final int NUM_ELEMENTS = 8;
// Number of elements
int[] userVals = new int[NUM_ELEMENTS];
// User numbers
int i = 0;
// Loop index
int sumVal = 0;
// For computing sum
// Prompt user to populate array
System.out.println("Enter " + NUM_ELEMENTS + " integer values...");
for (i = 0; i < NUM_ELEMENTS; ++i) {
System.out.print("Value: ");
userVals[i] = scnr.nextInt();
}
// Determine sum
sumVal = 0;
for (i = 0; i < NUM_ELEMENTS; ++i)
{
sumVal = sumVal + userVals[i];
}
System.out.println("Sum: " + sumVal); return;
}
}
Also, see attachment for source file
public class Student {
private String getFood() {
return "Pizza";
}
public String getInfo() {
return this.getFood();
}
}
public class GradStudent extends Student {
private String getFood() {
return "Taco";
}
public void teach(){
System.out.println("Education!");
getInfo();
}
}
What is the output from this:
Student s1 = new GradStudent();
s1.teach();
Education! would be printed, followed by a run-time error when getInfo is called.
Education! Pizza
This code won't run because it won't compile.
Education! Taco
This code causes a run-time error because getInfo is not declared in the GradStudent class.
Answer:
getInfo(); ==
getSy.Info()
Explanation:
Get System Info
A new operating system uses passwords that consist of three characters. Each character must be a digit between 0 and 9. For example, three distinct possible passwords are 123, 416, and 999. The system uses 32-bit salt values. The system also allows one login attempt every second and never locks out users regardless of how many failed attempts occur. If an adversary has obtained a copy of the password file and conducts an offline brute-force attack by trying every password combination until the adversary obtains username and password combination. The use of a 32-bit salt value
Answer:
Brute force is technique that is used for cracking password
In this case the system uses only three characters(0-9). By applying Brute force attack in "hit and try" manner we easily crack the password.
Explanation:
Solution
There are a wide variety of password cracking mechanisms.Brute force is one of the popular password cracking technique.Brute force attack is generally used to crack small passwords.
In the given example the system uses only three characters(0-9).By using Brute force attack in "hit and try" manner we easily crack the password.There are only 10 possible passwords for this type of system.Because we can arrange 0-9 only in 10 ways.But for Systems with long passwords it is difficult to find it in hit and try manner.But instead of having plain password each password have a random salt value.
In a system of 32 bit salt value there are 2^32 different key values.
By increasing the salt value from 32 bits to 64 bits there are 2^64 different key values.It increases the time taken to crack a password for an attacker.so by changing salt value from 32 to 64 bits will make it more harder for the adversary's attack to be successful.
Given the array [13, 1, 3, 2, 8, 21, 5, 1] suppose we choose the pivot to be 1 the second element in the array. Which of the following would be valid partitions?
A. 1 [1, 2, 3, 5, 8, 13, 21]
B. 1 [13, 1, 3, 2, 8, 21, 5]
C. 1 [13, 3, 2, 8, 21, 5, 1]
D. [1] 1 [13, 3, 2, 8, 21, 5]
E. [13] 1 [3, 2, 8, 21, 5, 1]
F. [13, 1, 3, 2, 8, 21, 5] 1 2/4
Answer:
D. [1] 1 [13, 3, 2, 8, 21, 5]
Explanation:
Using a quicksort with 1 as the pivot point, elements less than 1 will be sorted to the left of 1 and the other elements are greater than one will be sorted to the right of 1. The order doesn't matter. So we sort [1] to the left of 1 and [13, 3, 2, 8, 21, 5] to the right of 1. So, D. [1] 1 [13, 3, 2, 8, 21, 5] is the valid partition.
You can add additional design elements to a picture by adding a color background, which is accomplished by using what Paint feature?
Pencil tool
Shapes tool
Color Picker tool
Fill with Color tool
Answer:
Fill with Color tool
Two of the most fundamental functions for dealing with interprocess communication are read() and write(). Consider the following otherwise valid C program:int r, pipeFDs[2];
char message[512];
pid_t spawnpid;
pipe(pipeFDs);
spawnpid = fork();
switch (spawnpid)
{
case 0:
close(pipeFDs[0]); // close the input file descriptor
write(pipeFDs[1], "hi process, this is the STUFF!!", 21);
break;
default:
close(pipeFDs[1]); // close output file descriptor
r = read(pipeFDs[0], message, sizeof(message));
printf("Message received from other: %s\n", message);
break;
}
Select each of the following answers that is correct. CAN BE MULTIPLE CHOICES...
(1) The read() call may block until data becomes available
(2) When the read() call returns, this one call will return all of the data that was sent through the pipe, which is different behavior than if this was a socket
(3) If the read() call blocks, the process will be suspended until data arrives
(4) The write() call will return before all of the data has been written, if the corresponding read() call blocks mid-transfer
(5) Pipes can fill, which will cause the write() call to block until the read() call is able to read data from the pipe
Answer: Provided in the explanation section
Explanation:
int r, pipeFDs[2];
char message[512];
pid_t spawnpid;
pipe(pipeFDs);
spawnpid = fork();
switch (spawnpid)
{
case 0:
close(pipeFDs[0]); // close the input file descriptor
write(pipeFDs[1], "hi process, this is the STUFF!!", 21);
break;
default:
close(pipeFDs[1]); // close output file descriptor
r = read(pipeFDs[0], message, sizeof(message));
printf("Message received from other: %s\n", message);
break;
}
Observation of the program:
The read() call may block until data becomes available If the read() call blocks, the process will be suspended until data arrives Pipes can fill, which will cause the write() call to block until the read() call is able to read data from the pipe⇒ Therefore,Option 1,3 and 5 correct
Cheers i hope this helped !!!
Account Balance Design a hierarchy chart or flowchart for a program that calculates the current balance in a savings account. The program must ask the user for:________.
A- The starting balance
B- The total dollar amount of deposits made
C- The total dollar amount of withdrawals made
D- The monthly interest rate
Once the program calculates the current balance, it should be displayed on the screen.
Answer:
a. starting balance
Explanation:
A program that calculates the current balance of a savings should ask the user for the starting balance and then ask for the annual interest rate. A loop should then iterate once for every month of the savings period in order to perform other tasks such as asking the user for the total amount deposited into the account, the total amount withdrawn from the account, and calculate the interest rate. The program will then proceed to display the result at the end of the savings period.
In which situations would it be most helpful to filter a form? Check all that apply.
Filtering is a useful way to see only the data that you want displayed in Access databases.
What is a large public computer network through which computers can exchange information at high speed?
Answer:
Server
Explanation:
The Question is vauge, but I believe a Server is the word you're looking for. Computer Network could mean various things, in this case im going to assume that by Network, its saying Server. As a server is what allows for high speed interactions between a host computer and a client computer.
Write a program that reads integers start and stop from the user, then calculates and prints the sum of the cubes (=> **3) of each integer ranging from start to stop, inclusive. "Inclusive" means that both the values start and stop are included.
Answer:
This program is written in python programming language
Comments are used for explanatory purpose;
Take note of indentations(See Attachment)
Program starts here
#Initialize Sum to 0
sum = 0
#Prompt user for start value
start= int(input("Start Value: "))
#Prompt user for stop value
stop= int(input("Stop Value: "))
#Check if start is less than stop
if(start<=stop):
#Iterate from start to stop
for i in range(start, stop+1, 1):
sum+=i**3
else:
print("Start must be less than or equal to Stop")
#Display Result
print("Expected Output: ",sum)
#End of Program
An assault on system security that derives from an intelligent act that is a deliberate attempt to evade security services and violate the security policy of a system is a(n) _________.
A. Risk
B. Attack
C. Asset
D. Vulnerability
Answer:
Option B: Attack
Explanation:
A security attack is an act to access to a system without a legit authorization. Usually the aim is to steal confidential info from the system or control the system by manipulating the data stored in the system. Some attacks are also aimed to disable the operation of the hacked system. Nowadays, there are several common types of security attacks which include
phishingransomwaredenial of servicemain in the middleSQL injectionmalwareConsider the following class definitions.
public class Robot
{
private int servoCount;
public int getServoCount()
{
return servoCount;
}
public void setServoCount(int in)
{
servoCount = in;
}
}
public class Android extends Robot
{
private int servoCount;
public Android(int initVal)
{
setServoCount(initVal);
}
public int getServoCount()
{
return super.getServoCount();
}
public int getLocal()
{
return servoCount;
}
public void setServoCount(int in)
{
super.setServoCount(in);
}
public void setLocal(int in)
{
servoCount = in;
}
}
The following code segment appears in a method in another class.
int x = 10;
int y = 20;
/* missing code */
Which of the following code segments can be used to replace /* missing code */ so that the value 20 will be printed?
A Android a = new Android(x);
a.setServoCount(y);
System.out.println(a.getServoCount());
B Android a = new Android(x);
a.setServoCount(y);
System.out.println(a.getLocal());
C Android a = new Android(x);
a.setLocal(y);
System.out.println(a.getServoCount());
D Android a = new Android(y);
a.setServoCount(x);
System.out.println(a.getLocal());
E Android a = new Android(y);
a.setLocal(x);
System.out.println(a.getLocal());
Answer:
The correct answer is option A
Explanation:
Solution
Recall that:
From the question stated,the following segments of code that should be used in replacing the /* missing code */ so that the value 20 will be printed is given below:
Android a = new Android(x);
a.setServoCount(y);
System.out.println(a.getServoCount());
The right option to be used here is A.
Based on the information given, the code segments that's appropriate will be A Android a = new Android(x);
a.setServoCount(y);System.out.println(a.getServoCount());From the question stated, it was inferred that we should get the segments of code that should be used in replacing the /* missing code */ so that the value 20 will be printed.
This will be:
Android a = new Android(x);
a.setServoCount(y);
System.out.println(a.getServoCount());
In conclusion, the correct option is A.
Learn more about codes on:
https://brainly.com/question/22654163
Which of the following is an example of joint problem solving?
Explanation:
There is a high degree of informality to these relationships, which are focused on information sharing, joint-problem solving and joint operations.
A hallmark of most of these processes is their informality, whether through information sharing, joint problem solving or joint operations.
Global joint problem-solving team. In addition to requesting a division of labour, the Global Task Team recommendations called upon the World Health Organization (WHO), UNICEF, the United Nations Population Fund (UNFPA), the United Nations Development Programme (UNDP), the World Bank, the UNAIDS Secretariat and the Global Fund to take the lead in and establish the joint United Nations system-Global Fund problem-solving team by July # in order to support efforts that address implementation bottlenecks at the country level
Create a Python program that: Allows the user to enter a person's first name and last name. The user should be able to enter as many names as they desire. Create a function that takes the first name and last name, puts them together with the last name first, followed by the first name; with the names separated by commas. Take the result from the function, and place the resulting name in a list. Once the user finishes entering names, sort the contents of the list. Write the sorted names from a list into a text file. When you create the text file, allow the user to enter a name for the file to be created. After you finish writing names to the file, close the file and end the program.
Answer:
#main function start
def main():
#list to store names entered by user
name_list=[]
#variable to take input from user to keep rotating the loop and take input from user again and again
ch='y'
fname=""
lname=""
while ch=='y' or ch=='Y':#keep the loop taking input from user till user do not want to enter more
#take input from user
name=[]
fname=input("Enter first name: ")
lname=input("Enter last name: ")
name.append(fname)
name.append(lname)
#append the previously input first and last name in main list
name_list.append(name)
ch=input("Do you want to continue: (y/Y for yes)")
#main function end
#get file name from user
filename=input("Enter output file name")
#open file in write mode
file=open(filename,"w")
#keep loop add data in file till main list 'name_list' have
for i in name_list:
#Write data in file
file.write("%s, %s\r\n" % (i[0],i[1]))
#close the file
file.close()
#call main function
main()
Explanation:
input the above code and see output
In the lab, you defined the information systems security responsibility for each of the seven domains of a typical IT infrastructure. In which domain would you be most likely to secure access through the Internet and from employees’ homes?
Answer:
Remote Access Domain
Explanation:
Remote access Domain allows users to enter into system network through VPN.
A laptop computer has two internal signals: An unplugged signal, which is '1' if the laptop's power supply is connected, and '0' otherwise. A low battery signal, which is '0' if the laptop's battery has reached an almost empty state, and '1' otherwise. Suppose the laptop's power control system accepts a single hibernate signal which determines if the laptop should change its current operating state and shut down. If the laptop should shut down when the battery is low and its charger is unplugged, which gate could be used to produce the hibernate signal?
Answer:
The correct usage is a NOR gate which is indicated in the explanation.
Explanation:
The truth table for the given two signals, namely
p=unplugged signal
q=low battery signal
can form a truth table of following form
Here p has 2 states
1 if the power supply is connected
0 otherwise
Similarly q has 2 states
0 if the battery has reached almost zero state
1 otherwise
As the condition for the Hibernate Signal is given as to only activate when the battery is low and the power supply is not connected. This indicate that the value of Hibernate signal should be 1 when both p and q are 0.
Using this condition, the truth table is formed as
unplugged signal | low battery signal | Hibernate Signal
0 | 0 | 1
0 | 1 | 0
1 | 0 | 0
1 | 1 | 0
Now the truth table of NOR is given as
a | b | a or b | ~(a or b)
0 | 0 | 0 | 1
0 | 1 | 1 | 0
1 | 0 | 1 | 0
1 | 1 | 1 | 0
This indicates that the both truth tables are same thus the NOR gate is to be used for this purpose.
Probability of theft in an area is 0.03 with expected loss of 20% or 30% of things with probabilities 0.55 and 0.45. Insurance policy from A costs $150 pa with 100% repayment. Policy with B, costs $100 pa and first $500 of any loss has to be paid by the owner. Which data mining technique can be used to choose the policy?
Answer:
Decision trees
Explanation:
Decision trees mainly include categorization and estimation. It is often used as a measure of selection. This also encourages the usage and choice of particular data within the overall structure.
In the given situation, we should choose Policy A has cost $150 as it has 100% repayment while on the other hand Policy B has cost $100 and the first $500 of loss would be paid by the owner
So for choosing the policy, we use the decision tree data mining technique as we have to take the decision with respect to minimizing the cost
Data mining technique which can be used to choose the policy is decision tree.
The data mining technique that can be used are as follows,
Categorization and estimate are the two major functions of decision trees,Decision tree frequently used as a selection criterion. This promotes the use and selection of specific data within the broader framework.According to given data,
We should pick Policy A, which costs $150 and has a 100% payback rate.Whereas, the owner would be responsible for the first $500 of loss under Policy B, which costs $100.Here choosing the correct policy, decision tree is used.
Learn more: brainly.com/question/15247828
The new Director of Information Technology has asked you to recommend a strategy to upgrade the servers on their network. Recommendations on server hardware, CPU chip set, speed, and caching are needed. You should also recommend which servers to upgrade first and determine whether any servers are still appropriate to keep.
Answer:
servers to be upgraded are : APPLICATION AND LOAD BALANCING SERVERS
servers still appropriate to use : DNS AND DHCP SERVERS
Explanation:
The recommendations to be made in line with what the new director of information is asking for includes :
1 ) For the servers to be upgraded : The servers that requires upgrades includes the APPLICATION SERVER and LOAD BALANCING SERVER. this is because these two servers are critical to the growth/expansion of any business, and they handle large volume of data
Recommendations on the servers upgrade includes:
Hardware : 2.3 GHz Intel Xeon Gold 5118 12-Core
CPU chip set : Socket: FCLGA3647, Type: NSBM
Speed : processor 3.2 GHz
caching: > 100 Gb
2) For servers that do not necessarily need to be upgraded : The servers that do not need immediate upgrade are DNS and DHCP
Write a function PrintShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." numCycles times, where N is the cycle number, followed by "Done.". End with a newline. Example output for numCycles = 2:
1: Lather and rinse.
2: Lather and rinse.
Done.
Hint: Define and use a loop variable.
Sample program:
#include
using namespace std;
int main() {
PrintShampooInstructions(2);
return 0;
}
Answer:
public static void PrintShampooInstructions(int numberOfCycles){
if (numberOfCycles<1){
System.out.println("Too Few");
}
else if(numberOfCycles>4){
System.out.println("Too many");
}
else
for(int i = 1; i<=numberOfCycles; i++){
System.out.println(i +": Lather and rinse");
}
System.out.println("Done");
}
Explanation:
I have used Java Programming language to solve this
Use if...elseif and else statement to determine and print "Too Few" or "Too Many".
If within range use a for loop to print the number of times
Answer:
#In Python
def shampoo_instructions(num_cycles):
if num_cycles < 1: ///
print ('Too few.') ///
elif num_cycles > 4:
print ('Too many.')
else:
i = 0
while i<num_cycles:
print (i+1,": Lather and rinse.")
i = i + 1
print('Done.')
user_cycles = int(input())
shampoo_instructions(user_cycles)
Explanation:
def shampoo_instructions(num_cycles): #def function with loop
if num_cycles < 1: #using 1st if statement
print('Too few.')
elif num_cycles > 4:
print ('Too many.')
else:
i = 0
while i<num_cycles:
print (i+1,": Lather and rinse.")
i = i + 1
print('Done.')
user_cycles = int(input())
shampoo_instructions(user_cycles)
Write a program that lets the Michigan Popcorn Company keep track of their sales for seven different types of popcorn they produce: plain, butter, caramel, cheese, chocolate, turtle and zebra. It should use two parallel seven-element arrays: an array of strings that holds the seven popcorn names and an array of integers that holds the number of bags of popcorn sold during the past month for each popcorn flavor. The names should be stored using an initialization list at the time the flavors array is created. The program should prompt the user to enter the number of bags sold for each flavor. Once the popcorn data has been entered, the program should produce a report for each popcorn type, total sales, and the names of the highest selling and lowest selling products. Be sure to include comments throughout your code where appropriate. Complete the C++ code using Visual Studio or Xcode, compress (zip) and upload the entire project folder to the Blackboard assignment area by clicking on the Browse My Computer button or by dragging the file inside the Attach Files box g
Answer:
#include <iostream>using namespace std;int main(){ // declare and initialize popcorn name array string popcorn_name[7] = {"plain", "butter", "caramel", "cheese", "chocolate", "turtle", "zebra"}; // declare and initialize sales array with 7 elements int sales[7]; // A loop to prompt user to enter sales for each popcorn for(int i=0; i < 7; i++){ cout<<"Enter number of sales for " + popcorn_name[i] + " :"; cin>>sales[i]; } // Find maximum sales int max = sales[0]; int maxIndex = 0; for(int j=1; j < 7; j++){ if(max < sales[j]){ max = sales[j]; maxIndex = j; } } // Find minimum sales int min = sales[0]; int minIndex = 0; for(int k=1; k < 7; k++){ if(min > sales[k]){ min = sales[k]; minIndex = k; } } // Print popcorn name and sales for(int l=0; l < 7 ; l++){ cout<<popcorn_name[l]<<"\n"; cout<<"Sales: "<< sales[l]<<"\n\n"; } // Print popcorn name with maximum and minimum sales cout<<"Highest selling: "<< popcorn_name[maxIndex]<<"\n"; cout<<"Lowest selling: "<<popcorn_name[minIndex]<<"\n"; return 0;}Explanation:
Create two arrays to hold the list of popcorn name and their sales (Line 5-8). Next prompt user to input the sales for each popcorn (Line 10-14). Get the maximum sales of the popcorn (Line 17-24) and minimum sales (Line 27-34). Print the popcorn name and sales (Line 37-40) and the popcorn name with highest and lowest selling (Line 43-44).
Write a program in python that can compare the unit (perlb) cost of sugar sold in packages with different weights and prices. The program prompts the user to enter the weight and price of package 1, then does the same for package 2, and displays the results to indicate sugar in which package has a better price. It is assumed that the weight of all packages is measured in lb. The program should check to be sure that both the inputs of weight and price are both positive values.
Answer:
weight1 = float(input("Enter the weight of first package: "))
price1 = float(input("Enter the price of first package: "))
weight2 = float(input("Enter the weight of second package: "))
price2 = float(input("Enter the price of second package: "))
if weight1 > 0 and price1 > 0 and weight2 > 0 and price2 > 0:
unit_cost1 = price1 / weight1
unit_cost2 = price2 / weight2
if unit_cost1 < unit_cost2:
print("Package 1 has a better price.")
else:
print("Package 2 has a better price.")
else:
print("All the entered values must be positive!")
Explanation:
*The code is in Python.
Ask the user to enter the weight and the price of the packages
Check if the all the values are greater than 0. If they are, calculate the unit price of the packages, divide the prices by weights. Then, compare the unit prices. The package with a smaller unit price has a better price.
If all the entered values are not greater than 0, print a warning message
Write a program that asks the user to enter either an "African" or a "European" swallow. The programâs behaviour should mimic the program below. If the user enters something øther than "African" or "European", the program shøuld insult the user like the example below.
Sample Output #1:
What kind of swallow?
African
Yes, it could grip it by the husk.
Sample Output #2:
What kind of swallow?
European
A five-ounce bird could not carry a one-pound coconut.
Sample Output #3:
What kind of swallow?
Spanish
You really are not fit to be a king.
Answer:
The programming language is not stater; However, I'll answer this question using C++.
This program does not use comments (See explanation)
See Attachment for program file
Program starts here
#include <iostream>
using namespace std;
int main()
{
string response;
cout<<"What kind of swallow?\n";
cin>>response;
for(int i =0; i<response.length();i++)
{
response[i]=toupper(response[i]);
}
if(response == "AFRICAN")
{
cout<<"Yes, it could grip it by the husk.";
}
else if(response == "EUROPEAN")
{
cout<<"A five-ounce bird could not carry a one-pound coconut.";
}
else
{
cout<<"You really are not fit to be a king.";
}
return 0;
}
Explanation:
string response; -> A string variable to hold user input is declared
cout<<"What kind of swallow?\n"; -> prompts user for input
cin>>response; -> user input is stored here
The following iteration converts user input to uppercase; so that the program will work for inputs like African, AFRICAN, AFriCAN, etc.
for(int i =0; i<response.length();i++)
{
response[i]=toupper(response[i]);
}
The following if statement prints "Yes, it could grip it by the husk." if user input is AFRICAN
if(response == "AFRICAN")
{
cout<<"Yes, it could grip it by the husk.";
}
Otherwise, if user input is EUROPEAN, it prints; "A five-ounce bird could not carry a one-pound coconut."
else if(response == "EUROPEAN")
{
cout<<"A five-ounce bird could not carry a one-pound coconut.";
}
Lastly; for every inputs different from AFRICAN and EUROPEAN, the program displays "You really are not fit to be a king."
else
{
cout<<"You really are not fit to be a king.";
}
When law enforcement becomes involved, the need may arise to freeze systems as part of the evidence. There is also the likelihood that the incident will become known publicly. Do you think these issues play a significant part in the decision to involve law enforcement? Why or why not? Can you name some situations in which you believe that large organizations have decided not to involve law enforcement?
Answer:
Costs will cover a need for more customer data. The further explanation is given below.
Explanation:
It's the greatest problem for almost every company to provide the data with security. This is possible for highly trained practitioners and the technical staff to take charge of it. Complicated technologies would have been going to run together again to withstand these types of jobs.Such problems play a major part in the decision-making process affecting the law enforcement authorities to locate the suspects to strengthen the organization.To do something like this, there seem to be a lot of other good initiatives out there doing it.There have been some cases in which major corporations have chosen not to include law enforcement:
There are many more electronic corruption going on, including money robbery, asset fraud, as well as machine assaults. In such a bigger case, numerous institutions, such as large-scale ones, have gone through these circumstances to evaluate law enforcement to come to terms with cybersecurity.Shut down and unplug the computer. Remove the CPU case lid. Locate the various fans, and then use
compressed air to blow dirt out through the internal slits from inside the case.
Answer:
Cleaning the fan
Explanation:
Just did it on Ed
Would you mind giving me brainliest?
Write a program that displays the following pattern: ..\.\* .\.\*** \.\***** ******* \.\***** .\.\*** ..\.\* That is, seven lines of output as follows: The first consists of 3 spaces followed by a star. The second line consists of 2 spaces followed by a 3 stars. The third consists of one space followed by 5 stars, and the fourth consists just of 7 stars. The fifth line is identical to third, the sixth to the second and the seventh to the first. Your program class should be called StarPattern
Answer:
public class StarPattern {
public static final int MAX_ROWS = 7;
public static void main(String []args){
for (int row = 1; row <= MAX_ROWS; row++) {
int numOfSpaces = getNumberOfSpaces(row);
int numOfStars = MAX_ROWS - (getNumberOfSpaces(row) * 2);
String spaces = printSpaces(numOfSpaces);
String stars = printStars(numOfStars);
System.out.println(spaces + stars);
}
}
public static int getNumberOfSpaces(int row) {
int rowOffset = (MAX_ROWS / 2) + 1;
return Math.abs(row-rowOffset);
}
public static String printSpaces(int num) {
String result = "";
for (int i = 0; i < num; i++) {
result += " ";
}
return result;
}
public static String printStars(int num) {
String result = "";
for (int i = 0; i < num; i++) {
result += "*";
}
return result;
}
}
Explanation:
So it sounds we need to make a diamond shape out of asterisks like this:
*
***
*****
*******
*****
***
*
There are 7 rows and each row has up to 7 characters. The pattern is also symmetrical which makes it easier. Before writing any code, let's figure out how we are going to determine the correct amount of spaces we need to print. There are a lot of ways to do this, but I'll just show one. Let's call the 4th row y=0. Above that we have row 3 which would be y=-1, and below is row 5 which is y=1. With 7 rows, we have y=-3 through y=3. The absolute value of the y value is how many spaces we need.
To determine the number of stars, we just double the number of spaces, then subtract this number from 7. This is because we can imagine that the same amount of spaces that are printed in front of the stars are also after the stars. We don't actually have to print the second set of spaces since it is just white space, but the maximum number of characters in a row is 7, and this formula will always make sure we have 7.
I hope this helps. If you need help understanding any part of the code, jsut let me know.