Exercise 01_03:
public class Exercise01_03 {
public static void main(String args[])
{
//Printing to form the
pattern
System.out.println(" J
A V
V A");
System.out.println(" J A
A V V A
A");
System.out.println("J J
AAAAA V V
AAAAA");
System.out.println(" J
J A A
V A A");
}
}
Output:
Exercise 01_04:
public class Exercise01_04 {
public static void main(String args[])
{
int a;
System.out.println("a
a^2 a^3");
for(a = 1; a <= 4;
a++)//Displaying a, a^2, a^3
System.out.println(String.format("%s %8s %6s", a, (int)Math.pow(a,
2), (int)Math.pow(a, 3))); //Math.pow(a, 2) raises a to the power
of 2
//(int) converts data to
integer type
}
}
Output:
Exercise 01_10:
public class Exercise01_10 {
public static void main(String args[]){
int minutes = 45,
seconds = 30;
double distance = 14.0,
dist_In_1_hr, dist_In_miles;
seconds += minutes * 60;
//Calculating total seconds
dist_In_1_hr = 3600 *
distance / seconds; //Distance in km in one hour
dist_In_miles =
dist_In_1_hr / 1.6; //distance in miles
System.out.println(String.format("The average speed in miles = %.2f
mph.", dist_In_miles));
}
}
Output:
Exercise 01_11:
public class Exercise01_11 {
public static void main(String args[]){
int i;
double births, deaths,
immigrants, final_popu = 312032486.0, popu;
births = (365 * 24 *
3600) / 7.0; //Total births in a year
deaths = (365 * 24 *
3600) / 13.0; //Total deaths in a year
immigrants = (365 * 24 *
3600) / 45.0; //Total immigrants in a year
popu = births +
immigrants - deaths; //Population increase in a year
for(i = 1; i <= 5;
i++)
{
final_popu += popu; //Population at the end of each year
System.out.println("Year " + i + ": " +
(long)Math.ceil(final_popu)); //Population comes in whole
number
//Converting to long to display as whole number
//Taking ceiling value of the population
}
}
}
Output:
Write a program that displays the following pattern: Write a program that displays the following table:...
Need this done is java program coding in the simplest way possible. (Average speed in kilometers) Assume a runner runs 24 miles in 1 hour, 40 minutes, and 35 seconds. Write a program that displays the average speed in kilometers per hour. (Note that 1 mile is 1.6 kilometers.) 1.12
C++ (i) Write a program that displays the following pattern: * *** ***** ******* ***** *** * (ii) Katy bought 750 shares of stock at a price of $35.00 per share. She must pay her stockbroker a 2 percent commission for the transaction. Write a program that calculates and displays the following: The amount paid for the stock alone (without the commission) The amount of the commission) The total amount paid (stock plus commission) (iii) Write a program that...
java programming: Write a program that displays the following pattern (note you will need to use the escape sequences we learned in class to do this) &&&&&& & & & & & & & & &&&&&&
USING PYTHON LANGUAGE. QUESTION I: Write a program that displays the following table: a a^2 a 3 a14 1 1 1 1 2 4 8 16 3 9 27 81 4 16 64 256 QUESTION II: An approximate value of a number can be computed using the following formula: 7 ) Write a program that displays the result of 4 X + 7 • H) and 4 X - 를 7 tis). 9 QUESTION III: Write a program that prompts...
Write the PYTHON code that displays the following numbers: The program should have a header that displays "Number Doubled Tripled" above the start of the numbers. If putting all numbers on the same line, then they will need to be separated so you can see he individual number.(https://www.programiz.com/python-programming/methods/built-in/print) The program should display Every whole number from 1 through 35. The program should display that number doubled. The program should also display that number tripled. Make a working version of this...
Write a function (NOT a complete program) that displays the following picture. Use nested for loops inside of the program. ||#|@|#|(a) | # | @ # | @ #|(a) | # | @ You do not need to ask the user for input and can assume that there are only 6 columns
Write a Java application that displays the following output pattern: Thus, there are+signs everywhere except the diagonal, which has". "signs. There are no blank characters. Requirements and Restrictions: The number of lines and the number of characters per line, i.e. the size of the square pattern and line argument. For example, the size of the above square is 11 and it is specified through the following compile and execute commands: e >javac PrintPattern.java > java PrintPattern 11 Your program should...
Write a C program that reads a sequence of numbers and display a message 1. The numbers a re red from the standard input. 2. The first number is the length of the sequence (n) followed by n numbers. 3. If n is 0 or negative, the program displays the message "Error_1" followed 4. If the length is shorter than n, it displays "Error_2" followed by a new line 5. The program inspects the list and display one of the...
java Fill in the blanks to complete the following recursive program. It shou print a pattern like the one below. using System.out.println. Assume you have method String nspaces(n) which returns a string containing n spaces. You should not write nspaces.) The pattern below is of size 3. The first line has one space before the while the middle line has 3 spaces before the .. The program should work for any positive size. 3 public static gt ( if( }...
java program: Write a program which displays the following list on the screen and asks the user to enter either 1 or 2 and perform one of the operations based on the user’s input. If the user enters any other character other than 1 or 2 then display “wrong choice”. LIST OF OPERATIONS 1. Buzz Number 2. Consecutive Odd numbers Note: A BUZZ number is a number which either ends with 7 or is divisible by 7. Sample input 27...