The Beaufort Wind Scale is used to characterize the strength of winds. The scale uses integer values and goes from a force of 0, which is no wind, up to 12, which is a hurricane. The following script first generates a random force value. Then, it prints a message regarding what type of wind that force represents, using a switch statement. You are to rewrite this switch statement as one nested 150 CHAPTER 4: Selection Statements if-else statement that accomplishes exactly the same thing. You may use else and/or elseif clauses.
ranforce = randi([0, 12]); switch ranforce case 0 disp('There is no wind') case {1,2,3,4,5,6} disp('There is a breeze') case {7,8,9} disp('This is a gale') case {10,11} disp('It is a storm') case 12 disp('Hello, Hurricane!') end
Answer:
ranforce = randi([0, 12]);
if (ranforce == 0)
disp('There is no wind')
else if(ranforce>0 && ranforce <7)
disp('There is a breeze')
else if(ranforce>6 && ranforce <10)
disp('This is a gale')
else if(ranforce>9 && ranforce <12)
disp('It is a storm')
else if(ranforce==12)
disp('Hello, Hurricane!')
end
Explanation:
Replace all switch case statements with if and else if statements.
An instance is:
case {7,8,9}
is replaced with
else if(ranforce>9 && ranforce <12)
All other disp statements remain unchanged
Assume a 64KB cache with four-word block size (a word is 4 bytes) and a 32-bit address. If a block has 28 tag bits, what is the type of this cache
Answer:
Fully associative
Explanation:
Fully associative cache is a type of cache in which after retrieving the data from memory, it subsequently allows data to be deposited in the available but unused cache block. This is to ensure that the storage of cache is done without forcing each memory address into one specific block.
Given the following
address = 32 bits,
tag = 28 bits, as a block is 4 words that are, 4x4 bytes,
offset = 4 bits, which equates to index = 0 bits.
Hence, it can be concluded that the type of cache is FULLY ASSOCIATIVE.
Why are floppy disks obsolete ?
Answer:
they don't have enough space on them to carry useful information, and because most computers no longer have a drive for them. This is true for most legacy items
Can someone tell me why this code in Java won't run?
if (s.toLowerCase().equals(s.toUpperCase()))
{
System.out.println("*");
}
Answer:
try typing the following:
String lc = s.toLowerCase();
String uc = s.toUpperCase();
if(lc == uc){
System.out.println("*")
}
Adding a rock or stone looking characteristic to a background is which element of design?
Answer:
Explanation:
ejhdkl;xs
'