Write a program that accepts a four digit number, such as 1998, and displays it on number on a line, like: 1 9 9 8 The program should prompt for a four digit number. The program assumes that the user enters the correct information. Provide the java code, including a comment with your name, course code and date.

Answers

Answer 1
Answer:

package brainly;

import java.util.*;

/**

*

* @author CotrinaAlejandra

*/

public class Brainly {

   /*Provide the java code, including a comment with your name, course code and date.

   Name:  

   Course:  

   Date: */

   public static void main(String[] args) {

       // TODO code application logic here

       int number;

       Scanner sc = new Scanner(System.in);

       System.out.print("Write a four digit number: ");

       number=sc.nextInt();

       String newLine= String.valueOf(number);

       System.out.println(newLine.charAt(0)+"  "+newLine.charAt(1)+"  "+newLine.charAt(2)+"  "+newLine.charAt(3));

       

       

   }

   

}


Related Questions

Imagine that you only used assignment statements for the design of the seven-segment display decoder. How would you obtain the Boolean expressions for the seven segments? What would your VHDL design module code look like? Which way do you prefer designing the seven-segment display decoder, this way or by using the advanced VHDL statements you used in task 1?
You are tasked with writing a program to process sales of a certain commodity. Its price is volatile and changes throughout the day. The input will come from the keyboard and will be in the form of number of items and unit price:36 9.50which means there was a sale of 36 units at 9.50. Your program should read in the transactions (Enter at least 10 of them). Indicate the end of the list by entering -99 0. After the data is read, display number of transactions, total units sold, average units per order, largest transaction amount, smallest transaction amount, total revenue and average revenue per order.
Create an application (that uses the SortedABList) that allows a user to enter a list of countries that he or she has visited and then displays the list in alphabetical order, plus a count of how many countries are on the list. If the user mistakenly enters the same country more than once, the program should inform the user of their error and refrain from inserting the country into the list a second time.
g Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argument is "gravity" the method should display -"ytivarg". Demonstrate the method in a program that asks the user to input a string and then passes it to the method.
What is the speedup of going from a 1-issue processor to a 2-issue processor? use your code from part a for both 1-issue and 2-issue, and assume that 1,000,000 iterations of the loop are executed. as in part b, assume that the processor has perfect branch predictions, and that a 2-issue processor can fetch any two instructions in the same cycle?

The two ways to use the help menu is by searching of the contents or searching the _____ Menu
Index
File
Catalog

Answers

The two ways to use the help menu is by searching of the contents or searching the index.

Consider the following functions: (4) int hidden(int num1, int num2) { if (num1 > 20) num1 = num2 / 10; else if (num2 > 20) num2 = num1 / 20; else return num1 - num2; return num1 * num2; } int compute(int one, int two) { int secret = one; for (int i = one + 1; i <= two % 2; i++) secret = secret + i * i; return secret; } What is the output of each of the following program segments? a. cout << hidden(15, 10) << endl; b. cout << compute(3, 9) << endl; c. cout << hidden(30, 20) << " " << compute(10, hidden(30, 20)) << endl; d. x = 2; y = 8; cout << compute(y, x) << endl;

Answers

Answer:

a.  cout<<hidden(15,10)<<endl;

output = 5

b. cout << compute(3, 9) << endl;

output=3

c. cout << hidden(30, 20) << " " << compute(10, hidden(30, 20)) << endl;

output = 10

d. x = 2; y = 8; cout << compute(y, x) << endl;

output= 8

Explanation:

solution a:

num1= 15;

num2= 10;

according to condition 1, num1 is not greater than 20. In condition 2, num2 is also not greater than 20.

so,

the solution is

return num1 - num2 = 15 - 10 = 5

So the output for the above function is 5.

solution b:

as in function there are two  integer type variables named as one and two. values of variables in given part are:

one = 3

two = 9

secret = one = 3

for (int i= one + 1 = 3+1 = 4; i<=9%2=1; i++ )

9%2 mean find the remainder for 9 dividing by 2 that is 1.

//  there 4 is not less than equal to  1 so loop condition will be false and loop will terminate. statement in loop will not be executed.

So the answer will be return from function compute is

return secret ;

secret = 3;

so answer return from the function is 3.

solution c:

As variables in first function are num1 and num2. the values given in part c are:

num1 = 30;

num2= 20;

According to first condition num1=30>20, So,

num1= num2/10

so the solution is

num1 = 20/10 = 2

now

num1=2

now the value return from function Hidden is,

return num1*num2 = 2* 20 = 40

Now use the value return from function hidden in function compute as

compute(10, hidden(30, 20))

as the value return from hidden(30, 20) = 40

so, compute function becomes

compute(10, 40)

Now variable in compute function are named as one and two, so the values are

one= 10;

two = 40;

as

secret = one

so

secret = 10;

for (int i= one + 1 = 10+1 = 11; i<=40%2=0; i++ )

40%2 mean find the remainder for 40 dividing by 2 that is 0.

//  there 11 is not less than equal to  0 so loop condition will be false and loop will terminate. statement in loop will not be executed.

So the answer will be return from function compute is

return secret ;

secret = 10;

so answer return from the function is 10.

solution d:

Now variable in compute function are named as one and two, so the values are

one = y = 8

two = x = 2

There

Secret = one = 8;

So

for (int i= one + 1 = 8+1 = 9; i<=2%2=0; i++ )

2%2 mean find the remainder for 2 dividing by 2 that is 0.

//  there 9 is not less than equal to  0 so loop condition will be false and loop will terminate. statement in loop will not be executed.

So the answer will be return from function compute is

return secret ;

secret = 8;

so answer return from the function is 8.

Write a program to complete the task given below: Ask the user to enter any 2 numbers in between 1-10 and add both of them to another variable call z. Use z for adding 30 into it and print the final result by using variable results.

Answers

Answer:

a = int(input("Enter first value between 1 - 10"))

b = int(input("Enter second value between 1 - 10"))

z = a + b

z += 30

print("The value of z = ", z)

Explanation:

The code is written above in python language to perform the given task.

Now, let us explain each statement of code.

Step 1: The first two lines take input from the user prompting the user to enter the values between 1 to 10.

Then the values are type casted to int using int().

The values are stored in variables a and b.

Step 2: Then, the values of a and b are added to get another variable z.

Step 3: The statement 'z += 30' is equivalent to z = z+30

It adds 30 to the variable z and stores it in the same variable z.

Step 4: Finally the value of variable 'z' is printed using print() command.

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:

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

When you compose a message, you want your audience to find the information it needs quickly and to understand what it finds. Your message should be easy to read and to comprehend. Well-designed documents enhance readability and comprehension. Understanding and employing the various design techniques that can be used to improve readability will make your messages more effective. define the shape of text characters.

Answers

Answer:

Typefaces  is the correct answer to this question.

Explanation:

  • Typefaces define the word character shape. A typeface is a general term of a related family of fonts.
  • A broad range of typefaces is available for different purposes. Some are improving for unique purposes, and are helpful.
  • Nevertheless, one should look over serif or serif classifications for most business messages. Font alludes to a particular style within a family of typefaces.
  • Headings are a persuasive instrument for data presentation and meaningfulness enhancement.

Write a program to provide information on the height of a ball thrown straight up into the air. The program should request as input the initial height, h feet, and the initial velocity, v feet per second. The height of the ball after t seconds is

Answers

Answer:

The height of the ball after t seconds is h + vt - 16t 2 feet:

def main():

getInput()

def getInput():

h = int(input("Enter the initial height of the ball: ")) # Adding the int keyword before input() function

v = int(input("Enter the initial velocity of the ball: ")) # Same as above

isValid(h,v)

def isValid(h,v):

if ((h <= 0) or (v <= 0)):

print("Please enter positive values")

getInput()

else:

maxHeight(h,v)

def maxHeight(h,v):

t = (v/32)

maxH = (h + (v*h) - (16*t*t))

print ("\nMax Height of the Ball is: " + str(maxH) + " feet")

ballTime(h, v)

def ballTime(h,v):

t = 0

ballHeight = (h + (v*t) - (16*t*t))

while (ballHeight >= 0):

t += 0.1

ballHeight = (h + (v*t) - (16*t*t))

print ("\nThe ball will hit the ground approximately after " + str(t) + " seconds")

# Driver Code

main()

Answer:

I am writing a python code.

def getInput():

   h = int(input("enter the height: "))

   v = int(input("enter the velocity: "))

   isValid(h,v)    

def isValid(h,v):

   if (h<= 0 or v<=0):

       print("not positive ")            

   else:

       height = maximumHeight(h,v)

       print("maximum height of the ball is", height," ft.")

       balltime = ground_time(h,v)

       print("The ball will hit the ground after", balltime, "s approximately.")

def maximumHeight(h,v):

   t = (v/32)

   maxheight = (h + (v*t) - (16*t*t))

   return maxheight    

def ground_time(h,v):

   t = 0.1

   while(True):

       heightofball = (h + (v*t) - (16*t*t))

       if (heightofball <= 0):

           break

       else:

           t += 0.1  

   return t

Explanation:

There are four functions in this program.

getInput() function is used to take input from the user which is height and velocity. h holds  the value of height and v holds the value of velocity. input() function is used to accept values from the user.

isValid() function is called after the user enters the value of height and velocity. This function first checks if the value of height and velocity is less than 0. If it is true the message not positive is displayed. If its false then maximumHeight() is called which returns the maximum height of the ball and function ground_time() is called to return the time when the ball will hit the ground.

maximumHeight() function first divides the value of velocity with 32 as the ball will reach its maximum  height after v/32 seconds. It then returns the maximum height by using the formula:  heightofball = (h + (v*t) - (16*t*t)).

ground_time() calculates the time the ball takes to reach the ground. There is a while loop to height after every 0.1 second and determine when the height is no longer a positive. It uses (h + (v*t) - (16*t*t)) formula to calculate the height and when the value of height gets less than or equal to 0 the loop terminates otherwise it keeps calculating the height while adding 1 to the value of t at each iteration. After the loop breaks, it returns the value of t.

To see the output of the maximum height and time taken by ball to reach the ground, you can call the getInput() function at the end of the above program as:

getInput()

Output:

enter the height: 9

enter the velocity: 10

maximum height of the ball is 10.6525  ft.

the ball will hit the ground after 1.2 s approximately.