This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width.(1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt)
(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;
}
}

Answers

Answer 1
Answer:

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();    }


Related Questions

Language: JavaYour task is to complete the logic to manage a twenty-four-hour clock (no dates, just time) that tracksthe hours, minutes, and sections, and various operations to adjust the time. The framework for yourclock is in the Time class with the four methods you must complete.1.) advanceOneSecondâ A user calls this method to advance the clock by one second.a. When the seconds value reaches 60, it rolls over to zero.b. When the seconds roll over to zero, the minutes advance.So 00:00:59 rolls over to 00:01:00.c. When the minutes reach 60, they roll over and the hours advance.So 00:59:59 rolls over to 01:00:00.d. When the hours reach 24, they roll over to zero.So 23:59:59 rolls over to 00:00:00.2.) compareTo â The user wants to know if a second time is greater than or less than the timeobject called, assuming both are on the same date.a. Returns -1 if this Time is before otherTime.b. Returns 0 if this Time is the same as otherTime.c. Returns 1 if this Time is after otherTime.3.) add â Adds the hours, minutes, and seconds of another time (the offset) to the current timeobject. The time should ârolloverâ if it exceeds the end of a 24 hour period.4.) subtract â Subtracts the hours, minutes, and seconds of another time (the offset) fromthe current time object. The time should âroll backâ if it precedes the beginning of a 24 hourperiod.________________________________________________________________________package clock;/*** Objects of the Time class hold a time value for a* European-style 24 hour clock.* The value consists of hours, minutes and seconds.* The range of the value is 00:00:00 (midnight) to 23:59:59 (one* second before midnight).*/public class Time {private int hours;private int minutes;private int seconds;/*** Add one second to the current time.* When the seconds value reaches 60, it rolls over to zero.* When the seconds roll over to zero, the minutes advance.* So 00:00:59 rolls over to 00:01:00.* When the minutes reach 60, they roll over and the hours advance.* So 00:59:59 rolls over to 01:00:00.* When the hours reach 24, they roll over to zero.* So 23:59:59 rolls over to 00:00:00.*/public void advanceOneSecond(){}/*** Compare this time to otherTime.* Assumes that both times are in the same day.* Returns -1 if this Time is before otherTime.* Returns 0 if this Time is the same as otherTime.* Returns 1 if this Time is after otherTime.*/public int compareTo(Time otherTime){return 0;}/*** Add an offset to this Time.* Rolls over the hours, minutes and seconds fields when needed.*/public void add(Time offset){}/*** Subtract an offset from this Time.* Rolls over (under?) the hours, minutes and seconds fields when needed.*/public void subtract(Time offset){}
g A peer-to-peer PLC network: has no master PLC. uses the token passing access control scheme. each device is identified by an address. all of these.
Select the correct answer.At which stage of art criticism do you sum up your evaluations?A descriptionB. judgmentC. interpretationD. analysisResetNext
The advantages of automation include: (I) reduced output variability. (II) reduced variable costs. (III) machines don't strike or file grievances. (IV) machines are always less expensive than human labor.
If you pay a subscription fee to use an application via the internet rather than purchasing the software outright, the app is called a/an -- application.

a. Business, scientific, and entertainment systems are inherently complex. It is a well-known fact that systems can be better understood by breaking them down into individual tasks. Share how a programmer would use "top-down design" to understand better how a computer program should be designed. How do hierarchy charts aid the programmer?

Answers

Answer:

Explanation:

Top-down design allows a programmer to take a complex idea, break it down into high-level tasks which can be further broken down into more detailed sub-tasks (Evans, Martin, & Poatsy, 2018). The larger a program gets, the more important it is to have a clear design. It is easier to fix an error during the design phase than the coding phase. If the design is flawed, a programmer can end up having to delete or rewrite large portions of code. Reworking large portions of a design is preferable to rewriting large portions of code. Even small programs can become overwhelming with a number of tasks to perform. Hierarchy Chart (hierarchical diagram) shows the breakdown of a system to its lowest manageable parts. It is a top-down modular design tool, constructed of rectangles (that represents the different modules in a system) and lines that connect them. The lines explain the connection and/or ownership between the different modules among the system just like in an organizational chart. main purpose is to describe the structure and hierarchy of an entity. This entity could be a strategy, event, software program, and so on. The hierarchy chart is suitable in any situation that aims to present the organized structure of a material or an abstract entity.

Originally, Java was used to create similar apps as what other language?Perl
Python
CSS
Javascript

Answers

Originally, Java was used to create similar apps as other languages, which as python. The correct option is b.

What are computer languages?

The computer languages are Java and Python is in their conversion; the Java compiler converts Java source code into an intermediate code known as bytecode, whereas the Python interpreter converts Python source code into machine code line by line.

Curly braces are used in Java to define the beginning and end of each function and class definition, whereas indentation is used in Python to separate code into separate blocks.

Multiple inheritances is done partially through interfaces in Java, whereas Python continues to support both solitary and multiple inheritances.

Therefore, the correct option is b. Python.

To learn more about computer languages, refer to the below link:

brainly.com/question/14523217

#SPJ2

Answer:

Python

Explanation:

Took the test

Complete the sentence about a presentation delivery method. A(n) ____ allows you to transmit your presentations over the Internet using ____.

1: A. Presentation software
B. webcast
C. external monitor

2: A. Projectors
B. CDs
C. Streaming technology

Answers

A Presentation software allows you to transmit your presentation over the internet using CDs

Answer:

A Presentation software allows you to transmit your presentation over the internet using CDs??????????????????C

Cloud storage refers to the storage of data on ______.a. your mobile device.b. your desktop computer.c. an external drive.d. a server on the Interne.

Answers

The correct answer is:

Cloud storage refers to the storage of data on a server on the internet.

Every organization relies on data, In our daily job, we all make use of a huge amount of data(either in gigabytes or terabytes). And if you have a lot of files on your computer, it's probable that your computer may lose momentum and slow down, resulting in bad performance. While there are several external storage options available for storing and backing up your data, these devices are not infallible. Any incident, such as theft, or damage, might result in the loss of vital data.

This is where Cloud Storage comes into play. Cloud storage is a handy and dependable method of storing and retrieving information on the internet.

It is a cloud computing system in which data is stored on the server-side of the Internet and is managed and operated by a cloud computing provider. 

Therefore, from the above explanation, we can conclude that the correct Option is D

Learn more about Cloud Storage here:

brainly.com/question/23073532?referrer=searchResults

Answer:

D.  server on the internet

Explanation:

You text file begins with the following rows. The pattern is a description of the item to be repaired, its color, and the issue. bike, red, flat tire bike, blue, broken chain skate, blue, loose wheel mitt, red, torn lace Your program starts with the following lines. import csv aFile = open("data\broken.txt","r") aReader = csv.reader(aFile) countRed = 0 for item in aReader: When you write code to count the number of times red is the color, what is the index of "red"?

Answers

Answer: the answer is 1

Explanation:

edge 2021

An attempt to generate a large number of session IDs and have a server process them as part of a session hijack attempt is known as what type of attack

Answers

Answer:

An attempt to generate a large number of session IDs and have a server process them as part of a session hijack attempt is known as

TCP Session Hijacking.

Explanation:

TCP Session Hijacking is a cyber-attack in which illegitimate access is acquired to a client's server in the network.  The attacker then hijacks the TCP/IP session by reading and modifying transmitted data packets and also sending requests to the addressee's server.  To achieve this attack effectively, the hacker generates a large number of session IDs, thereby confusing the client's server to process them as a part of the users' sessions. Sessions (a series of interactions between two communication end points) are used by applications to store user parameters and, they remain alive until the user logs off.