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:
A bool can hold only true or false values.
A char can hold maximum 65535 characters.
An int can hold maximum positive value of 2,147,483,647.
A float can hold maximum positive value of 3.4 x 10^{38}.
Explanation:
Primitive data types in Java language can be categorized into boolean and numeric data types.
Numeric can be divided further into floating point and integral type. Floating data type includes float and double values while and integral data type which consists of char, int, short, long and byte data types.
Every data type has a range of values it can hold, i.e., every data type has a minimum and maximum predefined value which it is allowed to hold. The intermediate values fall in the range of that particular data type.
Any value outside the range of that particular data type will not compile and an error message will be displayed.
The data types commonly used in programming are boolean, char, int and float.
A boolean variable can have only two values, true or false.
A char variable can hold from 0 to 65535 characters. Maximum, 65535 characters are allowed in a character variable. At the minimum, a char variable will have no characters or it will be a null char variable, having no value.
An int variable has the range from minimum -2^{31} to maximum 2^{31} – 1. Hence, the maximum positive value an int variable can hold is (2^{31}) – 1.
A float variable can hold minimum value of 1.4 x 10^{-45} and maximum positive value of 3.4 x 10^{38}.
The above description relates to the data types and their respective range of values in Java language.
The values for boolean variable remain the same across all programming languages.
The range of values for char, int and float data types are different in other languages.
Answer:
RAID level 1 fits the criteria to yield the least amount of interference between the rebuild and ongoing disk accesses.
Explanation:
RAID system can be defined as the process in which hard drives which are connected to the system are been set up in order to help speed up the performance of a computer system disk storage which is why RAID is mostly used on servers and high performance computers system . This RAID as well helps to combines multiple physical disk drive components into various logical units for the aim of increasing system performance.
Therefore RAID level 1 fits the criteria to yield the least amount of interference between the rebuild and ongoing disk accesses. This is because the level 1 of RAID copies just the data from the failed Systems disk mirror during the rebuilding period where as the other levels of RAID copies the whole lot of content of the other disks due to the fact that RAID 1 often requires at least minimum of two physical drives because data is written simultaneously to two places in which the drives are essentially mirror images of one another in which if one fails, the other one can take over and help to provide access to the data that is been stored on that drive.
Answer:
Fill the blank with
public interface Nameable {
Explanation:
Required
Complete code segment with the interface definition
The given code segment is divided into three parts
1. The interface
2. The method that returns nothing
3. The method that returns string
The blank will be filled with the definition of the interface.
The definition is as follows:
public interface Nameable {
Analyzing the above definition
public -----> This represents the modifier
interface ------> This represents that the definition is an interface
Nameable ------> This represents the name of the interface
Answer:
print("enter starting time hours")
st_hours=int(input()) #starting time hours
print("minutes")
st_minutes=int(input()) #starting time minutes
print("enter ending time hours")
et_hours=int(input()) #ending time hours
print("minutes")
et_minutes=int(input()) #ending time minutes
cost=2.50
if (st_hours<21 and et_hours>21): #if starting time is less than 21 and ending time is greater than 21
a_hours=et_hours-21
a_minutes=et_minutes #taking time after 21 from ending time ending time-21
time_minutes=60-st_minutes #converting all the time into minutes
time_hours=21-(st_hours+1)
time_hours=time_hours*60
time=time_hours+time_minutes
cost=(cost/60)*time
time=(a_hours*60)+a_minutes
cost=cost+(1.75/60)*time
print("cost=$",cost)
elif(st_hours>=21): #if starting time is greater than 21
time_hours=et_hours-(st_hours+1)
time_minutes=(60-st_minutes)+et_minutes #converting time into minutes
time=(time_hours*60)+time_minutes
cost=(1.75/60)*(time)
print("cost=$",cost)
elif(et_hours<=21): #if ending time is less than 21
time_hours=et_hours-(st_hours+1)
time_minutes=(60-st_minutes)+et_minutes
time=(time_hours*60)+time_minutes
cost=(2.50/60)*time
print("cost=$",cost)
Explanation:
This is a conditional program, the conditions applied are if and else if.
The resultant output was gotten using this three steps:
(1) If starting time is less than 21 and ending time is greater than 21
Then I converted the time into minutes before 21
ex:- 8:30
21-9= 12*60= 720 + 30 = 750
Then I calculated the bill.
750 * (2.50 / 60)
Then I converted the time after 21 and then calculated the bill and printed it.
(2)If starting time is greater than 21
Converted time into minutes and multiplied it with (1.75 / 60) to get the bill.
(3) If ending time is less than 21
Converted time into minutes and multiplied it with (2.50 / 60) to get the bill.
Please check attachment for program code screenshot.
Answer:
The solution code is written in Python.
Explanation:
Firstly, use input() function to prompt user for a file name. (Line 1)
Next, we use input() function again to prompt user input a target character (Line 2)
Create a reader object and user read() method to copy entire texts from to the variable content (Line 4 - 5).
At last we can get the number of times the specified character appears in the file using the Python string built-in method count() (Line 6)
def __init__(self,size,idNum,color ):
self.size = size
self.location = 10
self.color = color
self.idNum = idNum
def changeLocation(self,newLocation):
self.location = newLocation
manipulator
initiator
method
constructor
Answer:
The answer is a method
Explanation:
Answer:
class and self
Explanation:
class Bike:
def __init__(self, str, float):
self.color = str
self.price = float