Answer:
web browser
Explanation:
the other three will not let her excess her page at all
The program is a sequential program; as such, it does not require loops or conditional statements.
The program in Python, where comments are used to explain each line is as follows:
#This gets input for the cost of the meal
cost = float(input("Cost: "))
#This initializes the local rate tax to 7.25%
local_rate_tax = 0.0725
#This initializes the tip to 18%
tip = 0.18
#This calculates the tax amount
taxAmount = cost * local_rate_tax
#This calculates the tip amount
tipAmount = cost * tip
#This calculates the grand total
grand = cost + taxAmount + tipAmount
#This prints the tax amount
print("Tax amount: {:.2f}".format(taxAmount))
#This prints the tip amount
print("Tip: {:.2f}".format(tipAmount))
#This prints the grand total
print("Grand total: {:.2f}".format(grand))
All outputs are formatted to 2 decimal places.
See attachment for sample run
Read more about similar programs at:
Answer:
Explanation
If I were calculating a tip at a restaurant using the same syntax, it would have been. meal ... New value of meal is double meal times tax. you're saying: (meal + meal) * tax but meal + meal * tax is calculated in the following order meal + (meal * tax) ... eh? ;) The exercise implied it was just reading the equation from right to left.
The electric bill program illustrates the use of loops (i.e. iteration)
Loops are used to execute repetitive operations
The electric bill program in Python where comments are used to explain each line is as follows:
#This iteration shows that the process is repeated for 50 consumers
for i in range(50):
#This gets input for the consumer name meter number
mno = input("Consumer name meter number: ")
#This gets input for last month reading
lmr = int(input("Last month reading: "))
#This gets input for current month reading
cmr = int(input("Current month reading: "))
#This calculates the number of units
Nou = cmr - lmr
#This calculates the bills
bill = Nou*2
#This calculates the tax
tax = bill*0.15
#This calculates the netbills
netbill = bill+tax
#This next four lines print the electric bills
print("Number of units:",Nou)
print("Bills:",bill)
print("Tax:",tax)
print("Netbill:",netbill)
Read more about loops at:
Answer:
outline 3 computer system problem that could harm people and propose the way avoid the problemare:_
Answer:
public class Main
{
public static void main(String[] args) {
minMax(1, 2, 3);
minMax(100, 25, 33);
minMax(11, 222, 37);
}
public static void minMax(int n1, int n2, int n3){
int max, min;
if(n1 >= n2 && n1 >= n3){
max = n1;
}
else if(n2 >= n1 && n2 >= n3){
max = n2;
}
else{
max = n3;
}
if(n1 <= n2 && n1 <= n3){
min = n1;
}
else if(n2 <= n1 && n2 <= n3){
min = n2;
}
else{
min = n3;
}
System.out.println("The max is " + max + "\nThe min is " + min);
}
}
Explanation:
*The code is in Java.
Create a function named minMax() that takes three integers, n1, n2 and n3
Inside the function:
Declare the min and max
Check if n1 is greater than or equal to n2 and n3. If it is set it as max. If not, check if n2 is greater than or equal to n1 and n3. If it is set it as max. Otherwise, set n3 as max
Check if n1 is smaller than or equal to n2 and n3. If it is set it as min. If not, check if n2 is smaller than or equal to n1 and n3. If it is set it as min. Otherwise, set n3 as min
Print the max and min
Inside the main:
Call the minMax() with different combinations
21
22
31
32
33
41
42
43
44
51
***
97
98
99
Note that the first numbers go from 1 to 9, and the second numbers start at 1 and go up to the
value of the first number (9 times). You must use loops to do this not 45 print statements.
Answer:
Explanation:
Program:-
public class Main{
public static void main(String args[]){
/* There are two for loops...
* First for loop runs from i=1 to i=9
* Second for loop runs from j=1 to j=i.
*
*/
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){ // j loop runs from j=1 to j=i
/*Prints I and j next to each other*/
System.out.println(i+""+j);
}//for loop of j ends here
}// for loop of I ends here
}
}
>>>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]