Answer:
please mark as brainliest!!
Explanation:
public class SumOfDigits{ public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Please enter a number to calculate sum of digits"); int number = sc.nextInt(); // Remember number/10 reduces one digit from number // and number%10 gives you last digit int sum = 0; int input = number; while (input != 0) { int lastdigit = input % 10; sum += lastdigit; input /= 10; } System.out.printf("Sum of digits of number %d is %d", number, sum); // closing Scanner to prevent resource leak sc.close(); } }
Answer:
To find the text file, use a full path name when entering the file name, such as
C:\textfiles\StateCapitals.txt
You can save typing in the full path name by putting the file in the project directory, such as in
C:\Users\me\Documents\NetBeansProjects\Project4
Answer:
C. top-down approach.
Explanation:
Structured application development uses a top-down approach in structural design, which is a process used to design application, by identifying the top functionalities is an application and splitting the to smaller modules where their tasks are simplified and specific.
It was introduced by IBM in the mid 1970s. It systematically shows the dataflow from the general structure to the detailed structure. This best suits systems with individual functions with little or no interaction.
Another type of approach to application structured design is the bottom-up approach.
Answer:
import random
def buildArray(a, b):
for i in range(b):
random_num = random.randint(10, 99)
a.append(random_num)
return a
def sumArray(arr):
total = 0
for e in arr:
total += e
return total
values = int(input("How many values to add to the array: "))
array = []
print(buildArray(array, values))
print("Total: " + str(sumArray(array)))
Explanation:
*Added parts are highlighted.
Create a method called sumArray that takes one parameter, arr
Initialize total as 0
Create a for loop iterates through arr
Add each value in the arr to the total
When the loop is done, return the total
After you build your array, call your method, sumArray, pass the created array as parameter and print the total
Explanation:
In its most basic form, each node contains:
data, and a reference (in other words, a
link) to the next node in the sequence. A
linked list whose nodes contain two fields:
an integer value and a link to the next node.
The last node is linked to a terminator used
to signify the end of the list.