Loop takes only positive numbers and terminates once it encounters a negative numbers.
Answer and Explanation:
Using javascript:
Var positiveInt= window.prompt("insert positive integer");
While(positiveInt>=0){
Alert("a positive integer");
Var positiveInt= window.prompt("insert positive integer");
}
Or we use the do...while loop
Var positiveInt= window.prompt("insert positive integer");
do{
Var positiveInt= window.prompt("insert positive integer");
}
While (positiveInt>=0);
The above program in javascript checks to see if the input number is negative or positive using the while loop condition and keeps executing with each input until it gets a negative input
Given two character strings s1 and s2. Write a Pthread program to find out the number of substrings, in string s1, that is exactly the same as s2
Answer:
Explanation:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MAX 1024
int total = 0 ;
int n1, n2;
char s1, s2;
FILE fp;
int readf(FILE fp)
{
if((fp=fopen("strings.txt", "r"))==NULL) {
printf("ERROR: can’t open string.txt!\n");
return 0;
}
s1=(char)malloc(sizeof(char)MAX);
if(s1==NULL) {
printf("ERROR: Out of memory!\n");
return 1;
}
s2=(char)malloc(sizeof(char)MAX);
if(s1==NULL) {
printf("ERROR: Out of memory!\n");
return 1;
}
/* read s1 s2 from the file */
s1=fgets(s1, MAX, fp);
s2=fgets(s2, MAX, fp);
n1=strlen(s1); /* length of s1 */
n2=strlen(s2)-1; /* length of s2 */
if(s1==NULL || s2==NULL || n1<n2) /* when error exit */
return 1;
}
int num_substring(void)
{
int i, j, k;
int count;
for(i=0; i<=(n1-n2); i++) {
count=0;
for(j=i, k=0; k<n2; j++, k++){ /* search for the next string of size of n2 */
if((s1+j)!=(s2+k)) {
break;
}
else
count++;
if(count==n2)
total++; /* find a substring in this step */
}
}
return total;
}
int main(int argc, char argv[])
{
int count;
readf(fp);
count=num_substring();
printf("The number of substrings is: %d\n", count);
return 1;
}
If the signal is going through a 2 MHz Bandwidth Channel, what will be the maximum bit rate that can be achieved in this channel? What will be the appropriate signal level?
Answer:
caca
Explanation:
Write a statement that assigns numCoins with numNickels + numDimes. Ex: 5 nickels and 6 dimes results in 11 coins. Note: These activities may test code with different test values. This activity will perform two tests: the first with nickels = 5 and dimes = 6, the second with nickels = 9 and dimes = 0.
1 import java.util.Scanner;
2
3 public class AssigningSum {
4 public static void main(String[] args) {
5 int numCoins;
6 int numNickels;
7 int numDimes;
8
9 numNickels = 5;
10 numDimes - 6;
11
12 /* Your solution goes here
13
14 System.out.print("There are ");
15 System.out.print(numCoins);
16 System.out.println(" coins");
17 }
18 }
Answer:
Explanation:
The statement solution was added to the code and then the code was repeated in order to create the second test case with 9 nickels and 0 dimes. The outputs for both test cases can be seen in the attached image below.
import java.util.Scanner;
class AssigningSum {
public static void main(String[] args) {
int numCoins;
int numNickels;
int numDimes;
numNickels = 5;
numDimes = 6;
/* Your solution goes here */
numCoins = numNickels + numDimes;
System.out.print("There are ");
System.out.print(numCoins);
System.out.println(" coins");
// TEST CASE 2
numNickels = 9;
numDimes = 0;
/* Your solution goes here */
numCoins = numNickels + numDimes;
System.out.print("There are ");
System.out.print(numCoins);
System.out.println(" coins");
}
}
Complete the AscendingAndDescending application so that it asks a user to enter three integers. Display them in ascending and descending order.An example of the program is shown below:Enter an integer... 1 And another... 2 And just one more... 3 Ascending: 1 2 3 Descending: 3 2 1GradingWrite your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade.Once you are happy with your results, click the Submit button to record your score.
Answer:
Following are the solution to the given question:
import java.util.Scanner;//import package
public class AscendingAndDescending//defining a class AscendingAndDescending
{
public static void main(String[] args) //main method
{
int n1,n2,n3,min,max,m;
Scanner in = new Scanner(System.in);//creating Scanner class object
System.out.print("Enter an integer: ");//print message
n1 = in.nextInt();//input value
System.out.print("And another: ");//print message
n2 = in.nextInt();//input value
System.out.print("And just one more: ");//print message
n3 = in.nextInt();//input value
min = n1; //use min variable that holds value
max = n1; //use mix variable that holds value
if (n2 > max) max = n2;//use if to compare value and hols value in max variable
if (n3 > max) max = n3;//use if to compare value and hols value in max variable
if (n2 < min) min = n2;//use if to compare value and hols value in min variable
if (n3 < min) min = n3;//use if to compare value and hols value in min variable
m = (n1 + n2 + n3) - (min + max);//defining m variable that arrange value
System.out.println("Ascending: " + min + " " + m + " " + max);//print Ascending order value
System.out.println("Descending: " + max + " " + m + " " + min);//print Descending order value
}
}
Output:
Enter an integer: 8
And another: 9
And just one more: 7
Ascending: 7 8 9
Descending: 9 8 7
Explanation:
In this program inside the main method three integer variable "n1,n2, and n3" is declared that inputs value from the user end and also defines three variable "min, max, and m" that uses the conditional statement that checks inputs value and assigns value according to the ascending and descending order and prints its values.
Write a program that launches 1,000 threads. Each thread adds 1 to a variable sum that initially is 0. You need to pass sum by reference to each thread. In order to pass it by reference, define an Integer wrapper object to hold sum. Run the program with and without synchronization to see its effect. Submit the code of the program and your comments on the execution of the program.
Answer:
Following are the code to the given question:
import java.util.concurrent.*; //import package
public class Threads //defining a class Threads
{
private Integer s = new Integer(0);//defining Integer class object
public synchronized static void main(String[] args)//defining main method
{
Threads t = new Threads();//defining threads class object
System.out.println("What is sum ?" + t.s);//print value with message
}
Threads()//defining default constructor
{
ExecutorService exe = Executors.newFixedThreadPool(1000);//defining ExecutorService class object
System.out.println("With SYNCHRONIZATION........");//print message
for(int i = 1; i <= 1000; i++)//defining a for loop
{
exe.execute(new SumTask2());//calling execute method
System.out.println("At Thread " + i +" Sum= " + s + " , ");//print message with value
}
exe.shutdown();//calling shutdown method
while(!exe.isTerminated())//defining while loop that calls isTerminated method
{
}
}
class SumTask2 implements Runnable//calling SumTask2 that inherits Runnable class
{
public synchronized void run()//defining method run
{
int value = s.intValue() + 1;//defining variable value that calls intvalue which is increment by 1
s = new Integer(value);//use s to hold value
}
}
}
Output:
Please find the attached file.
Explanation:
In this code, a Threads class is defined in which an integer class object and the main method is declared that creates the Threads class object and calls its values.
Outside the method, the default constructor is declared that creates the "ExecutorService" and prints its message, and use a for loop that calls execute method which prints its value with the message.
In the class, a while loop is declared that calls "isTerminated" method, and outside the class "SumTask2" that inherits Runnable class and defined the run method and define a variable "value" that calls "intvalue" method which is increment by 1 and define s variable that holds method value.
In this era of technology, everyone uses emails for mail and messages. Assume you have also used the
mailboxes for conversation. Model the object classes that might be used in Email system implementation
to represent a mailbox and an email message.
Assume You are working as a software engineer and now you have been asked to deliver a presentation to
a manager to justify the hiring of a system architect for a new project. Write a list of bullet points setting
out the key points in your presentation in which you explain the importance of software architecture
Answer:
A class may be a structured diagram that describes the structure of the system.
It consists of sophistication name, attributes, methods, and responsibilities.
A mailbox and an email message have certain attributes like, compose, reply, draft, inbox, etc.
Software architecture affects:
Performance, Robustness, Distributability, Maintainability.
Explanation:
See attachment for the Model object classes which may be utilized in the system implementation to represent a mailbox and an email message.
Advantages:
Large-scale reuse Software architecture is vital because it affects the performance, robustness, distributability, and maintainability of a system.
Individual components implement the functional system requirements, but the dominant influence on the non-functional system characteristics is that the system's architecture.
Three advantages of System architecture:
• Stakeholder communication: The architecture may be a high-level presentation of the system which will be used as attention for discussion by a variety of various stakeholders.
• System analysis: making the system architecture explicit at an early stage within the system development requires some analysis.
• Large-scale reuse:
An architectural model may be a compact, manageable description of how a system is organized and the way the components interoperate.
The system architecture is usually an equivalent for systems with similar requirements then can support large-scale software reuse..
Provide the EXACT C++ line of code necessary to return the heap-dynamic variable ptr to the operating system.
Full question:
Provide the EXACT C++ line of code necessary to return the heap-dynamic variable ptr to the operating system.
Pokemon *ptr;
ptr = new Pokemon[6];
Answer:
delete ptr;
Explanation:
The command in the answer above deallocates memory(preventing memory leaks) and returns control to the operating system.
The command in the question dynamically allocates memory to the the heap(dynamically allocated memory is called heap) while the program is running(different from statically allocated memory that allocates before program compiles). When the variable is no longer needed, deallocation occurs using the command in our answer where the variable is deleted using the pointer(keeps track of dynamic variables).
write an algorithm that reads to values, determines the largest value and prints the largest value with an identifying message
Answer:
I'm unsure of what language you are referring to, but the explanation below is in Python.
Explanation:
a = int(input("Input your first number: "))
b = int(input("Input your second number: "))
c = int(input("Input your third number: "))
maximum = max(a, b, c)
print("The largest value: ", maximum)
3. When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested?
A. Series
B. Parallel
C. Control
D. Line
Answer:
B. Parallel
Explanation:
When using the ohmmeter function of a digital multimeter, the leads are placed parallel to the component being tested. The digital multimeter is placed parallel to the component because, current has to flow into the component so as to be able to measure its resistance. Without the flow of current in the component, the resistance could not be measured.
If the component were placed in series, there would be no way to close the circuit because, we need a closed circuit so as to measure the resistance and use the ohmmeter function of the digital multimeter.
Only a parallel connection would close the circuit.
So, B is the answer.
Which of the following are issues in data integration? (which would actually cause conflicts) Question 4 options: Two different databases may have different column names for the same actual information (e.g. customer ID vs customer-id). Databases on related subjects that you want to integrate may have different numbers of columns or rows. An attribute named 'weight' may be in different units in different databases. There may be discrepancies between entries in two different databases for the same actual real-life entity (e.g. for an employee).
Answer:
The observed issues in data integration include the following from the listed options:
Two different databases may have different column names for the same actual information (e.g. customer ID vs customer-id).
There may be discrepancies between entries in two different databases for the same actual real-life entity (e.g. for an employee).
Explanation:
Data integration aims at consolidating data from disparate sources into a single dataset provide users with consistent access to data that will meet their various needs. However, the process of data integration faces many challenges. One of the challenges is disparate data formats and sources. There is also the velocity or speed at which data are gathered. For successful data integration, the different datasets need to be cleaned and updated with quality data.
Miguel has decided to use cloud storage. He needs to refer to one of the files he has stored there, but his internet service has been interrupted by a power failure in his area. Which aspect of his resource (the data he stored in the cloud) has been compromised
Answer: Availability
Explanation:
True or false, an implicitly unwrapped optional variable must have an exclamation mark affixed after it every time it is used. 答案选项组
Answer:
False.
Explanation:
Implicit unwrapped optional variables are those which are at option and they might be nil. It is not necessary that all implicit unwrapped optional variables should have an exclamation mark. Swift may eliminate the need for unwrapping.
_____ is one of the Rs involved in design and implementation of any case-based reasoning (CBR) application.
Answer:
Group of answer choices
React
Reserve
Reason
Retain
I am not sure if its correct
Retain is one of the Rs involved in design and implementation of any case-based reasoning (CBR) application.
What is Case Based Reasoning?Case-based reasoning (CBR) is a known to be a form of artificial intelligence and cognitive science. It is one that likens the reasoning ways as primarily form of memory.
Conclusively, Case-based reasoners are known to handle new issues by retrieving stored 'cases' and as such ,Retain is one of the Rs that is often involved in design and implementation of any case-based reasoning (CBR) application.
Learn more about Retain case-based reasoning from
https://brainly.com/question/14033232
Switched Ethernet, similar to shared Ethernet, must incorporate CSMA/CD to handle data collisions. True False
Answer:
False
Explanation:
The Carrier-sense multiple access with collision detection (CSMA/CD) technology was used in pioneer Ethernet to allow for local area networking. Carrier-sensing aids transmission while the collision detection feature recognizes interfering transmissions from other stations and signals a jam. This means that transmission of the frame must temporarily stop until the interfering signal is abated.
The advent of Ethernet Switches resulted in a displacement of the CSMA/CD functionality.
14. For the declaration, int a[4] = {1, 2, 3};, which one is right in the following description-
(
A. The meaning of &a[1] and a[1] are same B. The value of a[1] is 1-
C. The value of a[2] is 3
D. The size of a is 12 bytes
Answer:
A.
thanks later baby HAHAHAHAHAA
now now now now mowewweedeeee
Answer:
15
Inside the type declaration, you specify the maximum length the entry can be. For branch, it would be 15.
I can't seem to type the full "vc(15)" phrase because brainly won't let me.
Write code that prints: Ready! userNum ... 2 1 Go! Your code should contain a for loop. Print a newline after each number and after each line of text. Ex: If the input is: 3 the output is: Ready! 3 2 1 Go!
Answer:
Kindly find the code snippet in the explanation written in kotlin language
Explanation:
fun main(args: Array<String>) {
var num:Int
println("Enter a num")
num= Integer.valueOf(readLine())
for(i in num downTo 1){
if(i==num){
print("Ready!")
print(" ")
}
print(i)
print(" ")
if(i==1){
print(" ")
print("Go!")
}
}
}
This function too can also work
fun numTo(num:Int){
if (num>0) for(i in num downTo 1) print("$i ")
println("Go!")
Type the correct answer in the box. Use numerals instead of words. If necessary, use / for the fraction bar.
PH
var num2 = 32;
var num1 = 12;
var rem=num2 % numi;
while(rem > 0)
{
num2 = num1;
num1 = rem;
rem = num2 % num1;
}
document.write(num1);
The output of the document.write statement at the end of this block is
Answer:
4
Explanation:
Given
The attached code segment
Required
The output
The first and second lines initialize num2 to 32 and num1 to 12, respectively.
Next, the remainder is calculated on line 3
[tex]rem = 32\%12[/tex]
[tex]rem = 8[/tex]
Then the while loop is repeated as long as rem > 0.
At first, we have:
[tex]num2 = 32[/tex]
[tex]num1 = 12[/tex]
[tex]rem = 8[/tex]
The first iteration gives:
[tex]num2 = 12[/tex]
[tex]num1 = 8[/tex]
[tex]rem = 12\%8 = 4[/tex]
Is 4 > 0? Yes; The loop is executed again.
This gives:
[tex]num2 = 8[/tex]
[tex]num1 = 4[/tex]
[tex]rem = 8\%4=0[/tex]
Is 0 > 0? No; The loop is executed
The last statement prints the last value of num1;
In the last loop, we have:
[tex]num1 = 4[/tex]
Hence, the output is 4
Answer:
Below is correct, the answer is 4.
Explanation:
PLATO
You know different types of networks. If two computing station high speed network link for proper operation which of the following network type should be considered as a first priority?
MAN
WAN
WLAN
LAN
All of these
Answer:
All of these.
PLZ MARK ME BRAINLIEST.
Briefly explain what an array is. As part of your answer make use of a labelled example to show the declaration and components of an array
Answer:
Explanation:
In programming an array is simply a grouping of various pieces of data. Various data elements are grouped together into a single set and saved into a variable. This variable can be called which would return the entire set which includes all of the elements. The variable can also be used to access individual elements within the set. In Java an example would be the following...
int[] myArray = {33, 64, 73, 11, 13};
In Java, int[] indicates that the variable will hold an array of integers. myArray is the name of the variable which can be called to access the array elements. The elements themselves (various pieces of data) are located within the brackets {}
Choose all that Apply: Which of the following steps should be performed by the CIS for creating a part dispatch for systemboard through Tech Direct?
a) Enter the customer's contact and email address into the primary contact fields when requesting a systemboard through TechDirect
b) Logging fusion ticket to request DPK via DDL
c) Access the customer's DDL account to retrieve DPK and activate the os for the customer
d) Verify the customer email address
Answer:
The steps that should be performed by the CIS for creating a part dispatch for system board through TechDirect are:
a) Enter the customer's contact and email address into the primary contact fields when requesting a system board through TechDirect
b) Logging fusion ticket to request DPK via DDL
c) Access the customer's DDL account to retrieve DPK and activate the os for the customer
d) Verify the customer email address
Explanation:
The four steps given above must be performed in the CIS if you want to create a part dispatch for the system board through TechDirect. TechDirect is a support system that enables one to manage all Dell technologies from a single location. After creating the part dispatch, the customer's contact and email address are entered into the primary contact fields to enable the verification of the customer's email address through the TechDirect.
For the following 4-bit operation, assuming these register are ONLY 4-bits in size, which status flags are on after performing the following operation? Assume 2's complement representation. 1010+0110
a) с
b) Z
c) N
Answer:
All flags are On ( c, z , N )
Explanation:
Given data:
4-bit operation
Assuming 2's complement representation
Determine status flags that are on after performing 1010+0110
1 1
1 0 1 0
0 1 1 0
1 0 0 0 0
we will carry bit = 1 over
hence C = 1
given that: carry in = carry out there will be zero ( 0 ) overflow
hence V = 0
also Z = 1
But the most significant bit is N = 1
1. Describe data and process modeling concepts and tools.
Answer:
data is the raw fact about its process
Explanation:
input = process= output
data is the raw fact which gonna keeps in files and folders. as we know that data is a information keep in our device that we use .
Answer:
Data and process modelling involves three main tools: data flow diagrams, a data dictionary, and process descriptions. Describe data and process tools. Diagrams showing how data is processed, transformed, and stored in an information system. It does not show program logic or processing steps.
mention two strategies of collecting data
Write an application that finds the smallest of several integers. Assume that the first value read specifies the number of values to input from the user. C
Answer:
Following are the code to the given question:
#include<stdio.h>//include header file
int main() //defining a main method
{
int a[100],k,x,s; //defining integer variable and an array
printf("Input the number of element want to insert array: "); //print message
scanf("%d",&x); //input value
printf("Enter array value: \n"); //print message
for(k = 0; k<x; k++) //defining a loop that inputs values
{
scanf("%d",&a[k]); //use array to input value
}
s = a[0]; //holding first array value in array
for(k=0;k<x;k++) //use for loop
{
if(a[k]<s) //use if block to check the smallest array value
{
s=a[k];//holding smallest array value
}
}
printf("smallest number= %d",s);//print smallest value
}
Output:
Please find the attached file.
Explanation:
In this code an array and another integer variable "a[100], i,n, and s" is is declared, in which the array and n for input the value from the user-end.
In the next step, an "s" variable is declared that inputs the first array element value in s and use a loop to check the smallest array element and prints its value.
Jane is a full-time student on a somewhat limited budget, taking online classes, and she loves to play the latest video games. She needs to update her computer and wonders what to purchase. Which of the following might you suggest?
a. A workstation with a 3.9 GHz quad-core processor, 16 gigabytes of RAM, and a 24" monitor.
b. A laptop system with a 3.2 GHz processor. 6 gigabytes of RAM, and a 17" monitor.
c. A desktop system with a 1.9 GHz processor, 1 gigabyte of RAM, and a 13" monitor
d. A handheld PC (with no smartphone functionality)
Answer:
a. A workstation with a 3.9 GHz quad-core processor, 16 gigabytes of RAM, and a 24" monitor.
Explanation:
From the description, Jane needs to be able to multitask and run various programs at the same time in order to be efficient. Also since she wants to play the latest video games she will need high end hardware. Therefore, from the available options the best one would be a workstation with a 3.9 GHz quad-core processor, 16 gigabytes of RAM, and a 24" monitor. This has a very fast cpu with 4 cores to process various threads at the same time. It also has 16GB of memory to be able to multitask without problems and a 24" monitor. From the available options this is the best choice.
What order? (function templates) Define a generic function called CheckOrder() that checks if four items are in ascending, neither, or descending order. The function should return -1 if the items are in ascending order, 0 if the items are unordered, and 1 if the items are in descending order. The program reads four items from input and outputs if the items are ordered. The items can be different types, including integers, strings, characters, or doubles. Ex. If the input is:
Answer:
Explanation:
The following code was written in Java and creates the generic class to allow you to compare any type of data structure. Three different test cases were used using both integers and strings. The first is an ascending list of integers, the second is a descending list of integers, and the third is an unordered list of strings. The output can be seen in the attached image below.
import java.util.Scanner;
class Brainly {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Order: " + checkOrder(10, 22, 51, 53));
System.out.println("Order: " + checkOrder(55, 44, 33, 22));
System.out.println("Order: " + checkOrder("John", " Gabriel", "Daniela", "Zendaya"));
}
public static <E extends Comparable<E>> int checkOrder(E var1, E var2, E var3, E var4) {
E prevVar = var1;
if (var2.compareTo(prevVar) > 0) {
prevVar = var2;
} else {
if (var3.compareTo(prevVar) < 0) {
prevVar = var3;
} else {
return 0;
}
if (var4.compareTo(prevVar) < 0) {
return 1;
} else {
return 0;
}
}
if (var3.compareTo(prevVar) > 0) {
prevVar = var3;
}
if (var4.compareTo(prevVar) > 0) {
return -1;
}
return 0;
}
}
Java programming
*11.13 (Remove duplicates) Write a method that removes the duplicate elements from
an array list of integers using the following header:
public static void removeDuplicate(ArrayList list)
Write a test program that prompts the user to enter 10 integers to a list and displays
the distinct integers separated by exactly one space. Here is a sample run:
Enter ten integers: 34 5 3 5 6 4 33 2 2 4
The distinct integers are 34 5 3 6 4 33 2
Answer:
The program in Java is as follows:
import java.util.*;
public class Main {
public static void removeDuplicate(ArrayList<Integer> list){
ArrayList<Integer> newList = new ArrayList<Integer>();
for (int num : list) {
if (!newList.contains(num)) {
newList.add(num); } }
for (int num : newList) {
System.out.print(num+" "); } }
public static void main(String args[]){
Scanner input = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<Integer>();
System.out.print("Enter ten integers: ");
for(int i = 0; i<10;i++){
list.add(input.nextInt()); }
System.out.print("The distinct integers are: ");
removeDuplicate(list);
}}
Explanation:
This defines the removeDuplicate function
public static void removeDuplicate(ArrayList<Integer> list){
This creates a new array list
ArrayList<Integer> newList = new ArrayList<Integer>();
This iterates through the original list
for (int num : list) {
This checks if the new list contains an item of the original list
if (!newList.contains(num)) {
If no, the item is added to the new list
newList.add(num); } }
This iterates through the new list
for (int num : newList) {
This prints every element of the new list (At this point, the duplicates have been removed)
System.out.print(num+" "); } }
The main (i.e. test case begins here)
public static void main(String args[]){
Scanner input = new Scanner(System.in);
This declares the array list
ArrayList<Integer> list = new ArrayList<Integer>();
This prompts the user for ten integers
System.out.print("Enter ten integers: ");
The following loop gets input for the array list
for(int i = 0; i<10;i++){
list.add(input.nextInt()); }
This prints the output header
System.out.print("The distinct integers are: ");
This calls the function to remove the duplicates
removeDuplicate(list);
}}
How can COUNTIF, COUNTIFS, COUNT, COUNTA, and COUNTBLANK functions aide a company to support its mission or goals
Answer:
Following are the responses to these questions:
Explanation:
It employs keywords to autonomously do work tasks. Users can type numbers directly into the formulas or use the following formulae, so any data the cells referenced provide would be used in the form.
For instance, this leadership involves accounting, and Excel is concerned with organizing and organizing numerical data. In this Equation, I can discover all its information in the data. This idea is simple me count the number many cells containing a number, and also the number of integers. It counts integers in any sorted number as well. As both financial analysts, it is helpful for the analysis of the data if we want to maintain the same number of neurons.
This means that the surface area is composed of the base area (i.e., the area of bottom square) plus the side area (i.e., the sum of the areas of all four triangles). You are given the following incomplete code to calculate and print out the total surface area of a square pyramid: linclude > h: base azea- calcBasekrea (a) : cout << "Base auxface area of the squaze pyzamid is" << base area << "square feet."< endi: // add your funetion call to calculate the side ares and assign // the zesult to side area, and then print the result //hdd your function call to print the total surface area return 0F float calcBaseArea (float a) return pou (a, 2) /I add your function definicion for calcSideärea here // add your function definition tor prntSurfârea here This code prompts for, and reads in the side length of the base (a) and height of a square pyramid (h) in feet, and then calculates the surface area. The function prototype (i.e. function declaration), function definition, and function call to calculate and print the base area has already been completed for you. In the above program, a and h are declared in the main function and are local to main. Since a is a local variable, notice how the length a must be passed to calcBaseArea to make this calculation. One of your tasks is to add a new function called calesidearea that computes and returns the side area of the square pyramid. Given that the formula uses both the length a and height h of the square pyramid, you must pass these two local variables to this function. You will assign the returned value of this function to side area and then print the value to the terminal. Refer to what was done for calcBaseArea when adding your code. Your other task is to add a new function called prntsprfArea that accepts the base area and side area values (i.e, these are the parameters) and prints out the total surface area of the square pyramid inside this function. Since this function does not return a value to the calling function, the return type of this function should be void Now, modify the above program, referring to the comments included in the code. Complete the requested changes, and then save the file as Lab7A. opp, making sure it compiles and works as expected. Note that you will submit this file to Canvas
Answer:-
CODE:
#include <iostream>
#include<cmath>
using namespace std;
float calcBaseArea(float a);
float calcSideArea(float s,float l);
void prntSprfArea(float base_area,float side_area);
int main()
{
float h;
float a;
float base_area
float side_area;
cout<<"Enter the side length of the base of the square pyramid in feet : ";
cin>>a;
cout<<"Enter the height of the square pyramid in feet : ";
cin>>h;
base_area=calcBaseArea(a);
side_area=calcSideArea(a,h);
cout<<"Base surface area of the square pyramid is "<<base_area<<" square feet. "<<endl;
cout<<"Side area of the square pyramid is "<<side_area<<" square feet."<<endl;
prntSprfArea(base_area,side_area);
return 0;
}
float calcBaseArea(float a)
{
return pow(a,2);
}
float calcSideArea(float s,float l)
{
float area=(s*l)/2;
return 4*area;
}
void prntSprfArea(float base_area,float side_area)
{
cout<<"Total surface area of the pyramid is "<<base_area+side_area<<" square feet.";
OUTPUT: