PLEASE HELP!!!I need help with the following JAVA PROGRAMS.
Please ready carefully. So this comes from tony
gaddis starting out with java book. I have included the screenshot
of the problems for reference. I need HELP implementing these two
problems TOGETHER. There should be TWO class files. One which has
TWO methods (one to implement problem 8, and one to implement
problem 9). The second class should consist of the MAIN program
with the MAIN method which calls those methods. Thank you in
advance!!! Please let me know if you would like any
clarification!!! ALSO please include comments if possible
so I can understand better.
SumOfNos.java
import java.util.Scanner;
public class SumOfNos {
public int sumOfNosSeperatedByComma(String str)
{
int sum=0;
//Converting the String to String array
String arr[]=str.split(",");
for(int i=0;i<arr.length;i++)
{
//calculating the sum
sum+=Integer.parseInt(arr[i]);
}
return sum;
}
public void sumOfIndividualDigits(String str)
{
int sum=0,num;
int high,low;
//Converting String to char array
char arr[]=str.toCharArray();
high=Integer.parseInt(String.valueOf(arr[0]));
low=Integer.parseInt(String.valueOf(arr[0]));
//Calculating sum and find high and lowest digit
for(int i=0;i<arr.length;i++)
{
num=Integer.parseInt(String.valueOf(arr[i]));
sum+=num;
if(high<num)
high=num;
if(low>num)
low=num;
}
//Displaying the output
System.out.println("Sum = "+sum);
System.out.println("Highest Digit = "+high);
System.out.println("Lowest Digit = "+low);
}
}
____________________
Test.java
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
String str;
/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);
//Getting the input entered by the user
System.out.print("Enter Nos seperated by comma :");
str=sc.nextLine();
SumOfNos son=new SumOfNos();
//Displaying the output
System.out.println("Sum = "+son.sumOfNosSeperatedByComma(str));
//Getting the input entered by the user
System.out.print("Enter numbers :");
str=sc.next();
son.sumOfIndividualDigits(str);
}
}
_______________________
Output:
Enter Nos seperated by comma :7,9,10,2,18,6
Sum = 52
Enter numbers :2514
Sum = 12
Highest Digit = 5
Lowest Digit = 1
___________Thank You
PLEASE HELP!!!I need help with the following JAVA PROGRAMS. Please ready carefully. So this comes from...
Script 1: Sum of Numbers Write a python program that asks the user to enter a series of single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string. For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1, and 4.
c++ pleased
Assignment 6a (15 points] - Character and String related processing... Listed below are two interesting programming challenges that will require a bit of character and/or string related processing with functions. (Carefully read the specifications for each programming challenge and select ONE.) (1) Sum of Digits in a String Write a program that asks the user to enter a series of single-digit numbers with nothing separating them. Read the input as a C-string or a string object. The program...
Design a program in pseudocode that asks the user to enter a string containing a series of ten single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string except for the highest value digit. You may only use one main module and one sorting function; otherwise, do not modularize your program. For example, if the user enters 5612286470, the sum would be 33. (0+1+2+2+4+5+6+6+7) If there are multiple highest...
Need help answering the following using java 2a. Write a java program (just a “void main”) that will reverse the digits of a user entered, positive three-digit number. You can assume the user enters an integer. Your code segment should first verify that the user has entered a number from 100 to 999 (error message if not). If the user has entered a three-digit number, output a new number with the original digits reversed. 2b. Instead of being limited to...
I have to use java programs using netbeans. this
course is introduction to java programming so i have to write it in
a simple way using till chapter 6 (arrays) you can use (loops ,
methods , arrays)
You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...
I need the following written in Java please, thank you
'
We want you to implement a java class that will show details on users and throw exceptions where needed. The following requirements specify what fields you are expected to implement in your User class: - A private String firstName that specifies the first name of the user - A private String lastName that specifies the last name of the user - A private int age that specifies user's age...
Please I need help with this c++ code. please show all
steps , write comments and show sample runs. Thank you.
1. The Federal Bureau of Investigation (FBI) has recently changed its Universal Control Numbers (UCN) for identifying individuals who are in the FBI's fingerprint database to an eight-digit base 27 value with a ninth check digit. The digits used are: 0123456789ACDE FHJKLMNPRTVWX Some letters are not used because of possible confusion with other digits: B->8, G->C, I- >1, 0->0,...
I need help with the following assignment: Write an application named DailyTemps that continuously prompts a user for a series of daily high temperatures until the user enters a sentinel value of 999. Valid temperatures range from -20 through 130 Fahrenheit. When the user enters a valid temperature, add it to a total; when the user enters an invalid temperature, display the error message: Valid temperatures range from -20 to 130. Please reenter temperature. Before the program ends, display the...
I need help with this assignment. Please include comments throughout the program. Thanks Develop an algorithm and write the program in java for a simple game of guessing at a secret five-digit code. When the user enters a guess at the code, the program returns two values: the number of digits in the guess that are in the correct position and the sum of those digits. For example, if the secret code is 13720, and the user guesses 83521, the...
I wrote two java classes. One is main and other one is getter and setter. I brought methods from Digit class to Main class to print result. However, for some reason, only welcome print statement got printed and others got ignored. On the output screen, only welcome statement appear. nDigit should be input from user. import java.util.Scanner; public class Main { public static void main(String[] args) { Digit digitGet = new Digit(); ...