Answer:
The program written in C++ is as follows; (See Explanation Section for explanation)
#include <iostream>
using namespace std;
void revstring(string word)
{
string stringreverse = "";
for(int i = word.length() - 1; i>=0; i--)
{
stringreverse+=word[i];
}
cout<<stringreverse;
}
int main()
{
string user_input;
cout << "Enter a string: ";
getline (std::cin, user_input);
getstring(user_input);
return 0;
}
Explanation:
The method starts here
void getstring(string word)
{
This line initializes a string variable to an empty string
string stringreverse = "";
This iteration iterates through the character of the user input from the last to the first
for(int i = word.length() - 1; i>=0; i--) {
stringreverse+=word[i];
}
This line prints the reversed string
cout<<stringreverse;
}
The main method starts here
int main()
{
This line declares a string variable for user input
string user_input;
This line prompts the user for input
cout << "Enter a string: ";
This line gets user input
getline (std::cin, user_input);
This line passes the input string to the method
revstring(user_input);
return 0;
}
>>>lst = [4, 1, 2, -1]
>>>fun3(list)
-8
Answer:
Here is code in Python:
#function to swap first and last element of the list
#and calculate product of all elements of list
def fun3(e):
product = 1
temp = e[0]
e[0] = e[-1]
e[-1] = temp
for a in e:
product *= a
return product
#create a list
inp_lst = [4, 1, 2, -1]
#call the fun3() with parameter inp_lst
print("product of all elements of list is: ",fun3(inp_lst))
#print the list after swapping
print("list after swapping first and last element: ",inp_lst)
Explanation:
Create a list "inp_lst" and initialize it with [4,1,2,-1]. In the function fun3() pass a list parameter "e". create a variable "product" to calculate the product of all elements.Also create a temporary variable to swap the first and last element of the list.
Output:
product of all elements of list is: -8
list after swaping first and last element: [-1, 1, 2, 4]
Answer:
The c# program for the scenario is given below.
using System;
public class Program2 {
double total = 0;
static void Main() {
Program2 ob = new Program2();
Console.WriteLine("Enter total energy used in kilo watts ");
int p;
p = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter type of customer ");
char t;
t = Convert.ToChar(Console.ReadLine());
ob.bill_calculator(p, t);
Console.WriteLine("Total charge for " + p + " kilo watts electricity for " + t + " customers is " + ob.total);
}
public void bill_calculator(int e, char c)
{
int first=500, second = 800;
double chg_one = 0.12, chg_two=0.15, chg_three = 0.16, chg_four = 0.20;
if(c == 'R')
{
if(e <= 500)
{
total = (e * chg_one);
}
else if(e > 500)
{
total = ( first * chg_one);
total = total + ((e-first) * chg_two);
}
}
if(c == 'B')
{
if(e <= 800)
{
total = (e * chg_three);
}
else if(e > 800)
{
total = ( first * chg_three);
total = total + ((e-second) * chg_four);
}
}
}
}
OUTPUT
Enter total energy used in kilo watts
1111
Enter type of customer
B
Total charge for 1111 kilo watts electricity for B customers is 142.2
Explanation:
The program takes user input for the type of customer and the amount of electric current used by that customer.
The two input values decide the rate at which total charge is calculated.
For residential customers, charges are divided into slabs of 500 or less and more than 500.
Alternatively, for business customers, charges are divided into slabs of 800 or less and more than 800.
User input is taken in main function.
Charges are calculated in the bill_calculator method which takes both user input as parameters.
If else block is used to calculate the charges.
No input validation is implemented as it is not mentioned in the question.
All code is written inside the class. An object is created of the class.
The methods outside main() are called using the object of the class.
Answer:
D. Refrigerants
Explanation:
In the United States of America, the agency which was established by US Congress and saddled with the responsibility of overseeing all aspects of pollution, environmental clean up, pesticide use, contamination, and hazardous waste spills is the Environmental Protection Agency (EPA). Also, EPA research solutions, policy development, and enforcement of regulations through the resource Conservation and Recovery Act .
The Clean Air Act Amendments of 1990 prohibit service-related releases of all refrigerants such as R-12 and R-134a. This ban became effective on the 1st of January, 1993.
Refrigerants refers to any chemical substance that undergoes a phase change (liquid and gas) so as to enable the cooling and freezing of materials. They are typically used in air conditioners, refrigerators, water dispensers, etc.
The Clean Air Act Amendments of 1990 prohibit service-related releases of all refrigerants. The correct option is D.
Thus, The Environmental Protection Agency (EPA), which was formed by US Congress, is the organization tasked with regulating all facets of pollution, environmental cleanup, pesticide use, contamination, and hazardous material spills.
All refrigerants, including R-12 and R-134a, are forbidden from being released during service under the Clean Air Act Amendments of 1990. On January 1st, 1993, this ban came into force.
Any chemical compound that transforms into a different phase (liquid or gas) to allow for the cooling or freezing of items is referred to as a refrigerant. They are frequently found in refrigerators, water dispensers, air conditioners, and other appliances.
Thus, The Clean Air Act Amendments of 1990 prohibit service-related releases of all refrigerants. The correct option is D.
Learn more about Clean air act, refer to the link:
#SPJ3
PowerPoint
Web browser
Microchip
Answer:
its mircrochip
Explanation:
Answer:
i think either microchip or an app im not sure
the other answers smarter than mine make him brainliest
Explanation:
if (str.indexOf("pea") >= 0)
{
System.out.println("pea");
}
else if (str.indexOf("pear") >= 0)
{
System.out.println("pear");
}
else if (str.indexOf("pearl") >= 0)
{
System.out.println("pearl");
}
II.
if (str.indexOf("pearl") >= 0)
{
System.out.println("pearl");
}
else if (str.indexOf("pear") >= 0)
{
System.out.println("pear");
}
else if (str.indexOf("pea") >= 0)
{
System.out.println("pea");
}
Which of the following best describes the output produced by code segment I and code segment II?
Both code segment I and code segment II produce correct output for all values of str.
Neither code segment I nor code segment II produce correct output for all values of str.
Code segment II produces correct output for all values of str, but code segment I produces correct output only for values of str that contain "pear" but not "pearl".
Code segment II produces correct output for all values of str, but code segment I produces correct output only for values of str that contain "pearl".
Code segment II produces correct output for all values of str, but code segment I produces correct output only for values of str that contain "pea" but not "pear".
Answer:
Code segment II produces correct output for all values of str, but code segment I produces correct output only for values of str that contain "pea" but not "pear".
Explanation:
The main issue with the first code segment is the way how the if else if condition are arranged. The "pea" is checked at the earliest time in the first code segment and therefore so long as there is the "pea" exist in the string (regardless there is pear or pearl exist in the string as well), the if condition will become true and display "pea" to terminal. This is the reason why the code segment 1 only work for the values of str that contain "pea".
Answer:
C
Explanation: