CHALLENGE ACTIVITY 1.10.1: Sphere volume. Given sphereRadius and piVal, compute the volume of a sphere and assign sphereVolume with the result. Use (4.0 / 3.0) to perform floating-point division, instead of (4 / 3) which performs integer division. Volume of sphere = (4.0 / 3.0) π r3 (Hint: r3 can be computed using *)

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 2RQ
icon
Related questions
Question
CHALLENGE ACTIVITY
1.10.1: Sphere volume.
 
Given sphereRadius and piVal, compute the volume of a sphere and assign sphereVolume with the result. Use (4.0 / 3.0) to perform floating-point division, instead of (4 / 3) which performs integer division.

Volume of sphere = (4.0 / 3.0) π r3 (Hint: r3 can be computed using *)
 
 
CTU Class Homepage.
Section 1.1-CS 226T: Java Progrx
✰ learn.zybooks.com/zybook/CS226-2204A-03-2204A/chapter/1/section/13
=zyBooks My library > CS 226T: Java Programming home > 1.13: Characters
CHALLENGE
ACTIVITY
A common error is to use double quotes rather than single quotes around a character literal, as in myChar = "x", yielding a compiler error.
Similarly, a common error is to forget the quotes around a character literal, as in myChar = x, usually yielding a compiler error (unless x is
also a declared variable, then perhaps yielding a logic error).
CTU Messenger
422784.2543518.qx3zqy7
9
1.13.1: Printing a message with ints and chars.
Print a message telling a user to press the letter ToQuit key numPresses times to quit. End with newline. Ex: If letterToQuit = 'q' and
numPresses = 2, print:
Press the q key 2 times to quit.
1 import java.util.Scanner;
2
3 public class QuitScreen {
4
5
6
10
11
12
13
14
15 }
Run
public static void main(String[] args) {
new Scanner(System.in);
Scanner scnr
char letterToQuit;
int numPresses;
zy Section 1.13 - CS 226T: Java Prog X bHome | bartleby
zyBooks catalog
letterToQuit = scnr.next().charAt(0);
numPresses scnr.nextInt ();
/* Your solution goes here */
1 test
passed
All tests
passed
? Help/FAQ
Stacey Queen
X
:
12:24 PM
8/13/2022
Transcribed Image Text:CTU Class Homepage. Section 1.1-CS 226T: Java Progrx ✰ learn.zybooks.com/zybook/CS226-2204A-03-2204A/chapter/1/section/13 =zyBooks My library > CS 226T: Java Programming home > 1.13: Characters CHALLENGE ACTIVITY A common error is to use double quotes rather than single quotes around a character literal, as in myChar = "x", yielding a compiler error. Similarly, a common error is to forget the quotes around a character literal, as in myChar = x, usually yielding a compiler error (unless x is also a declared variable, then perhaps yielding a logic error). CTU Messenger 422784.2543518.qx3zqy7 9 1.13.1: Printing a message with ints and chars. Print a message telling a user to press the letter ToQuit key numPresses times to quit. End with newline. Ex: If letterToQuit = 'q' and numPresses = 2, print: Press the q key 2 times to quit. 1 import java.util.Scanner; 2 3 public class QuitScreen { 4 5 6 10 11 12 13 14 15 } Run public static void main(String[] args) { new Scanner(System.in); Scanner scnr char letterToQuit; int numPresses; zy Section 1.13 - CS 226T: Java Prog X bHome | bartleby zyBooks catalog letterToQuit = scnr.next().charAt(0); numPresses scnr.nextInt (); /* Your solution goes here */ 1 test passed All tests passed ? Help/FAQ Stacey Queen X : 12:24 PM 8/13/2022
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Concept of Threads
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT