Michael Adedire

Greenhorn

Posts: 1

posted 4 years ago

import java.util.Scanner;

public class SplitNum{

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print("Enter a 2 Digit integer");

int number = input.nextInt();

int ones = number / 10; // I THINK I MESSED UP RIGHT HERE

double tens = number / 10;

double sum = ones + tens;

System.out.println("The ones digit is " + ones + " , the number in the tens place is " + tens + " , and the sum of"

+ " the ones digit and the tens digit is " + sum);

System.out.println("Michael Adedire");

}

}

instructions

Program 3: SplitNum.java

Write a program that reads in a 2 digit integer (10 - 99). Your program should then print just

the number in the ones place, then on the next line just the number in the tens place, then on

the third line prints the sum of the two numbers. (Hint: Reminder division)

import java.util.Scanner;

public class SplitNum{

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print("Enter a 2 Digit integer");

int number = input.nextInt();

int ones = number / 10; // I THINK I MESSED UP RIGHT HERE

double tens = number / 10;

double sum = ones + tens;

System.out.println("The ones digit is " + ones + " , the number in the tens place is " + tens + " , and the sum of"

+ " the ones digit and the tens digit is " + sum);

System.out.println("Michael Adedire");

}

}

instructions

Program 3: SplitNum.java

Write a program that reads in a 2 digit integer (10 - 99). Your program should then print just

the number in the ones place, then on the next line just the number in the tens place, then on

the third line prints the sum of the two numbers. (Hint: Reminder division)

posted 4 years ago

Hello Michael,

Welcome to the Java Ranch.

That's an interesting problem however the next time when you post a problem please provide details on 'what is the problem that you are experiencing?'

Gauging by the code and the question that you have posted, I can see some obvious problems.

My suggestion to you would be to study the modulus operator for that is the key to this problem. Modulus Operator

Welcome to the Java Ranch.

That's an interesting problem however the next time when you post a problem please provide details on 'what is the problem that you are experiencing?'

Gauging by the code and the question that you have posted, I can see some obvious problems.

My suggestion to you would be to study the modulus operator for that is the key to this problem. Modulus Operator

Still a beginner at crafting quality coding but have the zeal to learn more. Your help would be appreciated.

My Blog on Learning Analytics

It is sorta covered in the JavaRanch Style Guide. |