QuestionQuestion

Transcribed TextTranscribed Text

Project 4.1 - In a recent episode of a popular lV show, a body was discovered lying at the bottom of some basement stairs lf the temperature of the bOdy upon d1scovery was 78 degrees and the basement was al a constan! temperature of 65 degrees, how IOng has the person been dead? Wñte a program that uses Newton's Law of Coollng to determine how many hours a person has been dead: In (!..=.l\ t=~ t = time in hOurs T = temperature of the body upon discovery (Fahrenheit) s = surroundmg temperature (Fahrenheit) D = 98 6 - S (normal t>ooy temperature - surrounding temperature) Prompt the user to enter values for T, the temperature of the body upon discovery (Fahrenheit) , and S, the surroundlng temperature Display the estimated 11me, r, to two decimal places For example: Ente:- the te~pe::-atu=e of the body upen d1.,cove:::y: 78 Ente= the .,u==oun::i.ing tet::t?e=atu::e: 65 :'he pe:::.,on ha., been dead fo::: 4. 81 hour., Please note that there iS no ln () method in tne Malll class , but lhere iS a method that will caleu1ate the natural IOganthm (see Table 4 2 In Sectk:m 4.2.2 Exponen! Methods for more info). Project 4.2 - Write a program that gets a single character from the user lf lile user enters more !han one character, use the first one Then determine whether that character iS a letter, number. or something etse lf it's a letter, determine 'Nhether it is a vowel or consonant. lf it's a number, determine whether it's odd or even. Here are a few example runs of llle program· Ente:- a .,:..ngle cha:::acte:::: o. a 1-' a lowe::: ca.,e vcwel Ente= a 5:..ngle characte::: : X X 1-' an uppe::: Cll-'I! con.,onant Ente:- a .,.:..ngle cha:::acte:::: 8 8 ._., an even numbe::: Ente:: a .,:..ng l e cha:::acte:::: 94 9 ::.., an odd nt.:...-.be.::: ?:n-i:e:-a ,-:.ngle character : 1 ! ::.., neithe::: a lette.::: or nu..-ibe.::: Project 5.1 - Mod1fy your solut1on from Pro¡ect 3.3 (the "Monday's Chlld" poem) to gel a number from the user mstead of generate a random number. Then, use a while loop w1th the followmg cond1tions· lf the u ser enters a 1 through 7, print out the appropñate line from the poem • 1 (Monday): Monday's chíld is faír of lace o 2 (Tuesday): Tuesday's ch1ld 1s full of grace • 3 (Wednesday): Wednesday's child 1s full of woe • 4 (Thursday¡· Thursday's child has far to go • 5 (Fñday): Fñday's chíld is lovíng and giving o 6 (Saturday): Saturday's ch1ld works hard for its living • 7 (Sunday): But the chíld that is born on the Sabbath day is bonny and bl1the, and good and gay lf the user enters a number greater than 7, let them know the number was invalíd lf the user enters a O, stop the program Here 1s an example: E~eer a n~r (O eo quie ) : 2 =ue~day•~ ch 1ld ~ ~ fu : l o f grace E~eer a n~r (O eo quic ) : 10 Sorry, 1nva: i d number E~eer a n~r (O eo quie ) : O Project 5.2 -Write a program that gets a phrase from the user Then use a IQ.rJ.QQRto exam1ne each letter ofthe phrase. Print out the position and character round at that position. Count how many times an 'A', 'E'. 'I', 'O'. or 'U' appears in the phrase . Your program should pfint out the characte r in the onginat case entered by the user, t>ut should treat 'a' and 'A' the same When countmg them. Here is an example. E:'lte::: a phra!!le: Win dwa rd Communit y College • 10 " 12 13 14 15 16 17 18 19 e 20 2: 22 23 2' 25 1 'A ' s 'E ' s 1 ' U' s Project 5.3 -Wnte a programt hat uses a ~P.. to get a numl>erl> etween5 an<:1I 5, inclustve, from u,e user Then use sorne IOopst o display a square and a tnangle ofthe numl>erth e user entere<.: !You can chOosew tlk:h type of IOopt o use, and you may have to nest one or more IOops together Here is an example Ente= a nu."!ll)er bet1~een 5 and 15: 2 pp1{marg1n:00 px00 px00 px00px,font 11.0pxMonaco} sor=y, 2 1~ in.va.lid . Plea~e ery again . Ente= a nu.Wer between 5 and 15: 20 Sorry, 20 i~ i!"lval!.d . Plea~e t:-y 4ga::.n . !.nter a nu.'!lber be ::.i~ee:1 5 a:1d 15 : 10 1 2 3 4 5 6 7 8 9 :o 1 2 3 4 5 6 7 8 9 10 2 3 4 6 1 8 9 :o 1 2 3 4 6 7 8 9 10 2 3 4 6 7 8 9 10 1 2 3 4 6 1 8 9 10 2 3 4 6 7 9 10 l 2 3 4 6 7 9 10 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 1 8 9 10 2 3 2 4 3 2 5 4 3 2 6 5 4 3 7 6 5 4 3 8165 432 98765432 10 9 8 7 6 5 4 3 2 1 1 1 1 1 1 2 2 3 2 3 4 2 3 4 5 2 4 5 6 2 4 5 6 7 2345678 234567 2 3 4 5 6 1 8 9 10 Project 8.1 - Modify yoursolution rrom Pro;ect 5.1 (the "Monday's Child" poem) to create a method that witl take in the numt>erentered by tne user, and then print out tlle appropriate line/message You sOOuld still nave a .wl:l.1!.t..P1-2tn2at will continue to prompt the user for a numoer unlil they entero to stop Use tne following metllod lleader · publie 5tatic vo::.d print!..ine (int nu.'Tlber) For example , if the user enters lile numt>er 5, you IHill pass it in to the printune() metllod , and lile line "FriClays clllk:I iS IOving and gMng~ shOuld t>e diSplayed t>y the metOOd. Tlle metllod WIII not retum anyth ing The Wtlile IOop in your maln() metllod sllOulCI slíll t>e getting the user input, and sllould call your printline() methocl lile printUne{) methocl should just decide wllicll line to print As a reminder , here are the lines of the poem and Wtlat should be printed for eacll number lf the u ser enters a 1 lllrougll 7, print out !lle appropriate line rrom !lle poem o 1 (Mond ay) Mondays cllild is fair of face o 2 (Tuesday) : Tuesdays cllild is full of grace o 3 (Wednesday) : Wednesday•s cllíld is full of woe o 4 (Thursday) : Thursdays cllild nas far to go o 5 (Frlday} : FriClays cllíld is IOving and giving o 6 (Saturday) : Saturdays child works hard for its living o 7 (Sunday): But the cllild tnat iS oorn on the sat>oath day is oonny and Dlithe, and good and gay lf the u ser enters a number greater tllan 7, let them know the numt>er was invaliCI lf tne user enters a O, stop !lle program The output of your program should t>e the same as in Project 51 Here is an example Ente:: a number (0 to quit): 2 Tuesday' s child :..5 fu:l cf g::ace E:"lee:: a nurnber (O to quit ) : 10 Sorry, 1nva:1d nu.-nber Ence:: a number (O ce quit ) : O Projec t 8.2 -Wrtte a program thal acts as a simple calculator First, a11owth e user to choose the opt10n to "add•, •subtract" . "muttIply", or "dMde" . Then get two numbers from the user. Depending on which opt10nt hey chose , you w,ll either add or muttIpty the two numt>ers together. subtract the second numt>er from lhe first, or divide the first number into the second You wIU need the followtng methods publl.c static void add(double nu.":ll, double nu.'112) publl.c static vo1d subtract(double nur.:11, double num2) public static double ~ultiply(double nur.:11, double nu.":12) public static double divl.de(double nu::i.l, double nu.'!l.2) The add (l and subtract () methods retum void, so the resun of addIng or subtractmg the numbers shOuld De displayed from wrthin those methods. Themultiply() and divide( ) methods shOuld retum the actual resutt ofmu hIplying ordlVidmg the numbers, so your main() method should take care of displaymg the result. Here iS an example : Calcula to:: cho:.ces : l . Add 2. Subt:::act 3. Multiply 4 . Divide Select choice: 1 !::nte:: f1rs': nu_-:ibe:::: 12. 6 Ente:: second nu.-nber: 9.1 12 . 6 ..- 9.1 = 2:. 'i Note: For lhis projeet, the calculator only needs to run once.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.Scanner;

public class Program53 {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int number;
do {
System.out.print("Enter a number between 5 and 15: ");
number = scanner.nextInt();

if(number < 5 || number > 15) {
System.out.println("Sorry, " + number + " is invalid. Please try again.");
}

}while(number < 5 || number > 15);

for(int i = 0; i < number; i++) {
for(int j = 0; j < number; j++) {
System.out.print((j+1) + " ");
}
System.out.println();
}

System.out.println();
for(int i = 0; i < number; i++) {

if(i < number-1) {
int n = i - 8;
if(n < 0) {
n = 0;
}
for(int k = number-9 -n; k > 0; k--) {
System.out.print(" ");
}
}

for(int j = number - i; j > 0; j--) {
System.out.print(" ");
}...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$30.00 $15.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Web Development (HTML, XML, PHP, JavaScript, Adobe, Flash, etc.) Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats