import java.util.Scanner; public class Probleml Collapse 3 public static void main(String[] args) Problem #1 Here are four sample outputs, your output should look exactly the same as follows: Enter integer n: 24 13 The sum of all digits of 24 is: 6 Enter integer n: 1305 The sum of all digits of 1305 is: 9 O% (1:0) Java Terminal codio@cable-fresh:-/workspace$ 0 Enter integer n: -24 The sum of all digits of -24 is: 6 Enter integer n: 10374 The sum of all digits of 10374 is: 15 TRY IT Problem1 Test Once your code works, press this button to submit it to the auto-grader

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
Codio
Project
File
Edit
Find
View
Tools
Education
Help
* Compile & Run
> Project Index (static)
O Debug Current File
MHAMEED7 O
Filetree
Problem1.java
Problem #1
1v
import java.util.Scanner;
public class Probleml
{
public static void main(String[] args)
{
MHAMEED7
Homework #3
2
Collapse
3
4
四
5
Problem #1
6.
A Homework #3 (master)
•I code
Here are four sample outputs, your output should look
O settings
O homework 3
O README.md
exactly the same as follows:
10
11
12
Enter integer ni 24
13
The sum of all digits of 24 is: 6
Enter integer n: 1305
The sum of all digits of 1305 is: 9
0% (1:0)
Java
Terminal
codio@cable-fresh:~/workspace 0
Enter integer n: -24
The sum of all digits of -24 is: 6
Enter integer n: 10374
The sum of all digits of 10374 is: 15
TRY IT
Problem1 Test
Once your code works, press this button to
submit it to the auto-grader
MacBook Air
Transcribed Image Text:Codio Project File Edit Find View Tools Education Help * Compile & Run > Project Index (static) O Debug Current File MHAMEED7 O Filetree Problem1.java Problem #1 1v import java.util.Scanner; public class Probleml { public static void main(String[] args) { MHAMEED7 Homework #3 2 Collapse 3 4 四 5 Problem #1 6. A Homework #3 (master) •I code Here are four sample outputs, your output should look O settings O homework 3 O README.md exactly the same as follows: 10 11 12 Enter integer ni 24 13 The sum of all digits of 24 is: 6 Enter integer n: 1305 The sum of all digits of 1305 is: 9 0% (1:0) Java Terminal codio@cable-fresh:~/workspace 0 Enter integer n: -24 The sum of all digits of -24 is: 6 Enter integer n: 10374 The sum of all digits of 10374 is: 15 TRY IT Problem1 Test Once your code works, press this button to submit it to the auto-grader MacBook Air
Problem #1
Complete the class Problem1, the program does the
following:
Prompt the user to enter an integer n.
• The program should find and print the sum of all digits of
the integer n.
for example, if n 341, the program should print 8 because
3+4 +1 = 8.
If n = 10374 the program should print 15 because 1 + 0 +
3 +7 + 4 = 15
• Also, if n = -10374, the program still prints the same value
as if n = 10374, think of a way to get the positive value of a
number all the time. Which method always returns the
positive value of any number?
Here are four sample outputs, your output should look
exactly the same as follows:
Enter integer n: 24
The sum of all digits of 24 is: 6
Enter integer n: 1305
Transcribed Image Text:Problem #1 Complete the class Problem1, the program does the following: Prompt the user to enter an integer n. • The program should find and print the sum of all digits of the integer n. for example, if n 341, the program should print 8 because 3+4 +1 = 8. If n = 10374 the program should print 15 because 1 + 0 + 3 +7 + 4 = 15 • Also, if n = -10374, the program still prints the same value as if n = 10374, think of a way to get the positive value of a number all the time. Which method always returns the positive value of any number? Here are four sample outputs, your output should look exactly the same as follows: Enter integer n: 24 The sum of all digits of 24 is: 6 Enter integer n: 1305
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,