Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This lab requires you to run two different programs. So, create projects named Lab05a, and Lab05b -- and use the default package names for those

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
This lab requires you to run two different programs. So, create projects named Lab05a, and Lab05b -- and use the default package names for those projects. Activity #1: Download the program named Draw Diamond.java. The program draws a diamond shape, i.e., a triangle with apex pointing up joined by lower triangle with apex down (See sample output 2). Program reads the height of the top triangle from the user. The height needs to be between 3 and 10. If the user enters an invalid size, the program objects and ends -- pausing to ensure that the user sees the message. Otherwise, the program continues on to draw the diamond. It first prints the top triangle, followed by the bottom triangle. The height of the bottom triangle is one less than the height of the top triangle. The code provided draws the upper triangle. Your task is to draw the lower triangle of the diamond shape. Use nested for loops to do the task. Sample outputl: Draw Diamond This program prints a diamond shapel By Jiju Poovancheri (A00000000) Please enter the height of the upper triangle: 2 That's not a valid size. I can only do shapes from 3 to 10 Quitting now. Press enter... Sample output2: Draw Diamond This program prints a diamond shapel By Jiju Poovvancheri (A00000000) Please enter the height of the upper triangle: 4 Diamond shape: Activity #2: Create program named Calculate Power.java. The program should implement the integer powering function, i.e. pow (x, n)=x" (x raised to n). The program reads the base (x) and exponent (n) from the user. It uses the loop to calculate X". You are not allowed to use Ja.puwU TUNCTIUNI U UU is ask, ricas HU UCIOW a Tew sample outputs. Sample outputl: Power Function This program calculates xn By Jiju Poovvancheri (A00000000) Please enter the base 10 Please enter the exponent 2 10^2 is 100 Sample output2: Power Function This program calculates xn By Jiju Poovvancheri (A00000000) Please enter the base 100 Please enter the exponent 4 100-4 is 100000000 Sample output3: Power Function This program calculates xn By Jiju Poovvancheri (A00000000) Please enter the base-2 Please enter the exponent 9 -29 is - 512

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

3. Are our bosses always right? If not, what should we do?

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago