Answer:
C
Explanation:
Enter the length of a side: 5
***** *****
***** * *
***** * *
***** * *
***** *****
Answer:
Here is the JAVA program.
import java.util.Scanner; //Scanner class to take input from user
public class HollowFilledSquare {
public static void main(String[] args) { //start of main() function body
Scanner sc= new Scanner(System.in); // Scanner class object
System.out.print("Enter an integer to display a filled and hollow square "); //prompts user to enter an integer
int n = sc.nextInt(); // reads integer input from the user
StringBuilder filled = new StringBuilder(n);
// creates objects filled and hollow of class StringBuilder
StringBuilder hollow = new StringBuilder(n);
for (int i = 1; i <= n; i++) { // outer loop for length of the square
for (int j = 1; j <= n; j++) { // inner loop for width of square
filled.append("*"); //displays asterisks
if (i == 1 || i == n || j == 1 || j == n) // condition to display stars
{hollow.append("*");}
else
{ hollow.append(" "); } } // to display empty spaces
System.out.println(filled + " " + hollow);
// places hollow and filled squares next to each other
filled. delete(0, filled.length());
//removes characters from 0 to the length of filled square
hollow. delete(0, hollow.length());
//removes characters from 0 to the length of hollow square } } }
Explanation:
The program first prompts the user to enter an integer. It uses outer loop for length of the square and inner loop for width of square in order to display the asterisks. append () function is used to display the sequence of asterisks. delete () function removes the asterisks from the sequence of asterisks. String Builder is a class used for to create a string of n characters. It basically works like String but this is used to create modifiable objects.
The screen shot of the code along with the output is attached.
A Python program can be written to read an integer that is then used to print out two squares of that side length with asterisks, one filled and one hollow. The provided Python code uses nested loops and conditionals to generate the squares accurately.
To complete your request, we would need to write a program to read an integer input and utilize this integer value to generate two squares with asterisks, one filled and one hollow. Here is a simple Python program:
def print_squares(n):This program first prints a filled square and a hollow square using conditionals to distinguish between the edge and inner positions of the squares.
#SPJ3
Answer:
import java.util.Arrays;
public class sort{
public static void main(String []args){
int[] arr = {2,6,9,1,5,3};
int n = arr.length;
Arrays.sort(arr);
for(int i=0;i<n;i++){
System.out.println(arr[i]);
}
}
}
Explanation:
first import the library Arrays for using inbuilt functions.
create the main function and define the array with elements.
then, use the inbuilt sort function in java which sort the array in ascending order.
syntax:
Arrays.sort(array_name);
then, use for loop for printing the each sorting element on the screen.
Answer:
System Interfaces.
Explanation:
Most new information systems must communicate with other, existing systems, so the design of the method and details of these communication links must be precisely defined. These are called system interfaces.
Answer:
// here is program in Java.
// import package
import java.util.*;
// class definition
class Main
{
// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// variable
int gall;
double cost=0;
// object to read value from user
Scanner scr=new Scanner(System.in);
// ask user to enter type
System.out.print("Enter customer type (R for residential or B for business ):");
// read type of customer
char t=scr.next().charAt(0);
if(t=='r'||t=='R')
{
System.out.print("enter the number of gallons:");
//read number of gallons
gall=scr.nextInt();
// if number of gallons are less or equal to 6000
if(gall<=6000)
{
// calculate cost
cost=gall*0.007;
// print cost
System.out.println("total cost is: "+cost);
}
else
{
// calculate cost
cost=(6000*0.005)+((gall-6000)*0.007);
// print cost
System.out.println("total cost is: "+cost);
}
}
else if(t=='b'||t=='B')
{
System.out.print("enter the number of gallons:");
//read number of gallons
gall=scr.nextInt();
// if number of gallons are less or equal to 8000
if(gall<=8000)
{
// calculate cost
cost=gall*0.006;
// print cost
System.out.println("total cost is: "+cost);
}
else
{// calculate cost
cost=(8000*0.006)+((gall-8000)*0.008);
// print cost
System.out.println("total cost is: "+cost);
}
}
}catch(Exception ex){
return;}
}
}
Explanation:
Ask user to enter the type of customer and assign it to variable "t" with scanner object.If the customer type is business then read the number of gallons from user and assign it to variable "gall". Then calculate cost of gallons, if gallons are less or equal to 8000 then multiply it with 0.006.And if gallons are greater than 8000, cost for first 8000 will be multiply by 0.006 and for rest gallons multiply with 0.008.Similarly if customer type is residential then for first 6000 gallons cost will be multiply by 0.005 and for rest it will multiply by 0.007. Then print the cost.
Output:
Enter customer type (R for residential or B for business ):r
enter the number of gallons:8000
total cost is: 44.0
Severe injuries or death
Neurological damage
Amputations
In almost all cases, touching power lines or coming into contact with energized sources will result in Severe injuries or death. Thus, option second is correct.
Electrical, mechanical, chemical, pneumatic, chemical, thermal, and other energy sources in machinery and equipment can be harmful to employees.
De-energization may entail turning off a machine and unplugging it, or removing a switch before applying a lock to prevent the equipment from being accidentally starting up. Lockout can be enforced once energization is complete.
Touching electricity lines or making contact with electrical sources will almost always result in severe injury or death. As a result, option two is correct.
Learn more about sources here:
#SPJ2
Answer:
Severe injuries or death
Explanation:
Answer:
#include <iostream>
#include <string>
using namespace std;
int main() {
string inputMonth;
int inputDay;
cin >> inputMonth >> inputDay;
if (inputMonth == "January" && inputDay >= 1 && inputDay <= 31)
cout << "Winter" << endl;
else if (inputMonth == "February" && inputDay >= 1 && inputDay <= 29)
cout << "Winter" << endl;
else if (inputMonth == "April" && inputDay >= 1 && inputDay <= 30)
cout << "Spring" << endl;
else if (inputMonth == "May" && inputDay >= 1 && inputDay <= 30)
cout << "Spring" << endl;
else if (inputMonth == "July" && inputDay >= 1 && inputDay <= 31)
cout << "Summer" << endl;
else if (inputMonth == "August" && inputDay >= 1 && inputDay <= 31)
cout << "Summer" << endl;
else if (inputMonth == "October" && inputDay >= 1 && inputDay <= 31)
cout << "Autumn" << endl;
else if (inputMonth == "November" && inputDay >= 1 && inputDay <= 30)
cout << "Autumn" << endl;
else if (inputMonth == "March" && inputDay >= 20 && inputDay <= 31)
cout << "Spring" << endl;
else if (inputMonth == "June" && inputDay >= 1 && inputDay <= 20)
cout << "Spring" << endl;
else if (inputMonth == "June" && inputDay >= 21 && inputDay <= 30)
cout << "Summer" << endl;
else if (inputMonth == "September" && inputDay >= 1 && inputDay <= 21)
cout << "Summer" << endl;
else if (inputMonth == "September" && inputDay >= 22 && inputDay <= 30)
cout << "Autumn" << endl;
else if (inputMonth == "December" && inputDay >= 0 && inputDay <= 20)
cout << "Autumn" << endl;
else if (inputMonth == "December" && inputDay >= 21 && inputDay <= 30)
cout << "Winter" << endl;
else if (inputMonth == "March" && inputDay >= 1 && inputDay <= 19)
cout << "Winter" << endl;
else
cout << "Invalid" << endl;
return 0;
}
Answer:
FOR PYTHON!!
input_month = input()
input_day = int(input())
months= ('January', 'February','March', 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , "October" , "November" , "December")
if not(input_month in months):
print("Invalid")
elif input_month == 'March':
if not(1<=input_day<=31):
print ("Invalid")
elif input_day<=19:
print("Winter")
else:
print ("Spring")
elif input_month == 'April' :
if not(1<=input_day<=30):
print("Invalid")
else:
print("Spring")
elif input_month == 'May':
if not(1<=input_day<=31):
print("Invalid")
else:
print("Spring")
elif input_month == 'June':
if not(1<=input_day<=30):
print("Invalid")
elif input_day<=20:
print ("Spring")
else:
print("Summer")
elif input_month == 'July':
if not(1<=input_day<=31):
print("Invalid")
else:
print("Summer")
elif input_month == 'August':
if not(1<=input_day<=31):
print("Invalid")
else:
print("Summer")
elif input_month == 'September':
if not(1<=input_day<31):
print("Invalid")
elif input_day<=21:
print ("Summer")
else:
print ("Autumn")
elif input_month == "October":
if not(1<=input_day<=31):
print("Invalid")
else:
print("Autumn")
elif input_month == "November":
if not(1<=input_day<=30):
print("Invalid")
else:
print ("Autumn")
elif input_month == "December":
if not(1<=input_day<=31):
print("Invalid")
elif input_day <=20:
print ("Autumn")
else:
print ("Winter")
elif input_month == 'January':
if not(1<=input_day<=31):
print("Invalid")
else:
print("Winter")
elif input_month == "February":
if not(1<=input_day<=29):
print("Invalid")
else:
print ("Winter")
Explanation:
Good luck in the rest of your class!