C++ program for calculating the average of scores
#include <iostream>
using namespace std;
const int n=5;//As per question only 5 test scores were there
int numbers[5];
void getscore(int i)//defining function for taking input
{
cin >> numbers[i];
while(numbers[i]<0 || numbers[i]>100)//score should be between 0 to 100
{
cout<<"\nThe number should be between 0 to 100\n";
cin>>numbers[i];
}
}
int main()//driver function
{
cout << "Enter 5 scores:\n";
for (int i = 0; i < n; i++)
{
getscore (i);//calling function each time for input
}
int s = 101;
double avg = 0;
for (int i = 0; i < n; i++)//loop for finding the smallest
{
s = numbers[i] < s ? numbers[i] : s;
}
for (int i = 0; i < n; i++) //loop for finding the Average
{
avg += numbers[i];
}
avg -= s;
avg /= 4;
cout << "Average of the four scores are: " << avg<< endl;//printing the output
return 0;
}
Output
Enter 5 scores:
4
5
6
7
8
Average of the four scores are: 6.5
Paging disk 98%
Other I/O devices 10%
For each of the following, indicate yes or no to say whether or not it will (or is likely to) improve CPU utilization:
a. Install a faster CPU
b. Install a bigger paging disk
c. Increase the degree of multiprogramming
d. Decrease the degree of multiprogramming
e. Install more main memory
f. Install a faster hard disk
g. Increase the page size
Answer:
a. Install a faster CPU - No
b. Install a bigger paging disk - No
c. Increase the degree of multiprogramming - No
d. Decrease the degree of multiprogramming - Yes
e. Install more main memory - Yes
f. Install a faster hard disk - Yes
g. Increase the page size - Yes
Explanation:
a. Install a faster CPU No.
Installing a faster CPU will not improve CPU utilization too much because the CPU utilization is low (20%) and the utilization of the paging disk is very high (98%), we can see that the system has lack of free memory.
b. Install a bigger paging disk No.
Installing a bigger paging disk doesn't improve the CPU utilization because the system has lack of free memory.
c. Increase the degree of multiprogramming No.
If the level of multiprogramming is increased more processes would have to be swapped in and out of the memory with a higher chance of page fault much frequently and the CPU utilization would reduce.
d. Decrease the degree of multiprogramming Yes.
If the level of multiprogramming is reduced less processes would have to be swapped in and out of memory, reducing the chance of page fault and the CPU utilization would improve.
e. Install more main memory
This is likely to improve CPU utilization as more pages can remain resident and not require paging to or from the disks.
f. Install a faster hard disk
With a faster hard disk, the CPU will get more data more quickly and this will lead to faster response and more throughput to the disks. With a faster hard disk, the disk is not a bottleneck to utilization.
g. Increase the page size
Increase the page size will likely degrade the performance, because the internal fragmentation will be worse, the utilization of main memory will be low, more processes will not be able to fit into main memory, and the system will have to spend more time in swapping. So this is as likely to decrease utilization as it is to increase it.
A.print(5 // totalItems)
B.print(totalItems // 5)
C.print(totalItems(5) )
D.print(5(totalitems) )
Answer:
B. Print Totalltems // 5
Explanation:
Well, if you learn how to create bundles on Amazon, you can eliminate the competition, set your price, and offer customers a product they’ll absolutely love.
Answer:
•Determine your IP address.
•Verify physical connectivity to the network.
•Check that you have a logical connection to the network.
•Find out what path network traffic takes to get to its destination.
Translate from DNS names to IP addresses.
(2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow base. (1 pt)
(3) Modify the given program to use a loop to output an arrow head of width arrowHeadWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow head. (2 pts)
(4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width. (1 pt)
while (arrowHeadWidth <= arrowBaseWidth) {
// Prompt user for a valid arrow head value
}
Example output for arrowBaseHeight = 5, arrowBaseWidth = 2, and arrowHeadWidth = 4:
Enter arrow base height:
5
Enter arrow base width:
2
Enter arrow head width:
4
**
**
**
**
**
****
***
**
*
This is what I have:
import java.util.Scanner;
public class DrawHalfArrow
{
public static void main(String[] args)
{
Scanner scnr = new Scanner(System.in);
int arrowBaseHeight = 0;
int arrowBaseWidth = 0;
int arrowHeadWidth = 0;
System.out.println("Enter arrow base height:");
arrowBaseHeight = scnr.nextInt();
System.out.println("Enter arrow base width:");
arrowBaseWidth = scnr.nextInt();
while (arrowHeadWidth >= arrowBaseWidth)
{
System.out.println("Enter arrow head width:");
arrowHeadWidth = scnr.nextInt();
}
// Draw arrow base (height = 3, width = 2)
for(int i=0; i < arrowBaseHeight; ++i)
{
for(int j=0; j < arrowBaseWidth; ++j)
{
System.out.print("*");
}
System.out.println();
}
// Draw arrow head (width = 4)
for(int i=0; i < arrowHeadWidth; ++i)
{
for(int j=0; j < arrowHeadWidth-i; ++j)
{
System.out.print("*");
}
System.out.println();
}
return;
}
}
Answer:
The modified program in Java is as follows:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int arrowHeadWidth, arrowBaseWidth, arrowBaseHeight;
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt();
System.out.print("Base Height: "); arrowBaseHeight = input.nextInt();
while (arrowHeadWidth <= arrowBaseWidth) {
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt(); }
for(int i = 0; i<arrowBaseHeight; i++){
for(int j = 0; j<arrowBaseWidth;j++){
System.out.print("*"); }
System.out.println(); }
for(int i = arrowHeadWidth; i>0;i--){
for(int j = 0; j<i;j++){
System.out.print("*"); }
System.out.println(); }
}
}
Explanation:
This declares the arrow dimensions
int arrowHeadWidth, arrowBaseWidth, arrowBaseHeight;
This get input for the head width
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
This get input for the base width
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt();
This get input for the base height
System.out.print("Base Height: "); arrowBaseHeight = input.nextInt();
This loop is repeated until the head width is greater than the base width
while (arrowHeadWidth <= arrowBaseWidth) {
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt(); }
This iterates through the base height
for(int i = 0; i<arrowBaseHeight; i++){
This iterates through the base width
for(int j = 0; j<arrowBaseWidth;j++){
This fills the base
System.out.print("*"); }
This prints a new line
System.out.println(); }
These iterate through the arrow head
for(int i = arrowHeadWidth; i>0;i--){
for(int j = 0; j<i;j++){
This fills the arrow head
System.out.print("*"); }
This prints a new line
System.out.println(); }
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.