Java: Start coding

First you need  an IDE (Integrated Development Environment). This is where you write and develop your code. If you don’t have one, I recommend Netbeans or Eclipse.

Below are links where you download either Netbeans or Eclipse…..

For Netbeans

(download the one that said JAVA SE)

For Eclipse

(download the one that said “Eclipse IDE for Java Developers” 32 bit is fine)


Just follow the common sense installation process ( clicking next, next, next…) and you will be good   🙂


If you are new to JAVA, before I start unleashing JAVA example problems to you and solutions codes……

glance through this web document below, from , to give yourself an introduction to Java.


Now, Here are some JAVA problems, and their solutions. I will start with the easy ones..

Study each problem and solution code to develop your coding skills….Some of the questions are my former instructor, David kirk’s question, that he gave us in his java class..  …

But the solutions are mine..Good luck


1. Create a program named  Declare the following variable:

String Sentence = “The quick brown fox jumped over the lazy dog.”;

Using string methods, have your program print the following information:

Sentence: The quick brown fox jumped over the lazy dog.

Length of Sentence:                 45
Sentence contains the word “big”:   false
Sentence contains the word “jump”:  true
Sentence ends with a period:        true
First 10 characters of Sentence:    The quick

Sentence after replacing all spaces with hyphens:

2. Create a program named  Using input dialog boxes or console input, prompt the user how many pennies, nickels, dimes, and quarters they have.  Using a message box or console output, tell the user the total dollar amount of money they have.

Solution to problem 1

public class Strings {
public static void main(String[] args) {
String sentence = “The quick brown fox jumped over the lazy dog.”;
String uppercase = sentence.toUpperCase();
int length = sentence.length();
boolean check1 = sentence.contains(“big”);
boolean check2 = sentence.contains(“jump”);
boolean check3 = sentence.endsWith(“.”);
String first10 = sentence.substring(0,10);
String replace = sentence.replace(” “,”-“);

System.out.println(“Length of Sentence:\t\t\t”+length);
System.out.println(“Sentence contains the word \”big\”:\t”+check1);
System.out.println(“Sentence contains the word \”jump\”\t:”+check2);
System.out.println(“Sentence ends with a period:\t\t”+check3);
System.out.println(“First 10 characters of Sentence:\t”+first10);
System.out.println(“First 10 characters of Sentence:\t”+replace);




Solution to problem 2

import java.util.Scanner;

* @author mosesike
public class Change {
public static void main(String[] args) {

Scanner key = new Scanner(;
System.out.print(“Enter how many PENNYS you have”);
double penny = key.nextInt();
System.out.print(“Enter how many NICKELS you have”);
double nickels = key.nextInt();
System.out.print(“Enter how many DIMES you have”);
double dimes = key.nextInt();
System.out.print(“Enter how many QUARTERS you have”);
double quarters = key.nextInt();
double total = penny/100 + nickels/20 + dimes/10 + quarters/4;
System.out.println(“Your total dollar amount is: $”+total);

total = total * 100;
int newquarters = (int)total/25;
int quarterRemainder = (int)total%25;
int newdimes = quarterRemainder/10;
int dimesRemainder = quarterRemainder%10;
int newnickels = dimesRemainder/5;
int nickelRemainder = dimesRemainder%5;
int newpennys = nickelRemainder;
System.out.println(“Your Fewest possible coins are:\n”
+ newquarters+” QUARTERS\n”
+newdimes+” DIMES\n”
+newnickels+” NICKELS\n”
+newpennys+” PENNYS”);



Okey Dokey, before I continue,  I am going to start making the solution downloadable so that you can download a text or zip file that contains its solution, to make it easier for you to manage…

Study and attempt the question first, before looking at the solution.

problem 3

Advark Sketch  problem and solution

problem 4

Create a program named  Ask the user which year they were born.  Tell the user their Chinese zodiac animal.

Hint:  Declare an array of Chinese zodiac animals:   String[] Zodiac = {“rat”,”ox”,”tiger”, etc.
You will need to use the modulus % operator.

China Zodiac Solution .txt

problem 5

Create a program named  Ask the user to enter a sentence.  Output the number of vowels, consonants, and words in the sentence.

Hint:  Create int variables V, C, and W.  Create a for loop that steps through each character in the sentence and increments the appropriate variable.

Sentence Soultion

problem 6

Create a program named  Ask the user to enter a Roman Numeral.  Output the numeric value of the Roman Numeral.
Test your program with these numbers:  MCMXLII, MCMLXIX, DCCCLXXXVIII

Hint: Create a for loop that steps through each character of roman numeral.M = 1000, D = 500, C = 100, L = 50, X = 10, V = 5, I = 1.MDCLXVI = 1000 + 500 + 100 + 50 + 10 + 5 + 1 = 1666


If a digit is out of order, then it is subtracted from the next digit.  This is only used for these combinations:

CM = 900, CD = 400, XC = 90, XL = 40, IX = 9, IV = 4

Roman solution

Problem 7

Write a program named that rolls a pair of dice 10,000 times.  It should track how many times each number (total of dice 2 – 12) is rolled.

Total On Dice    Number of Rolls

————-    —————

2              274

3              520

.               .

.               .

.               .

12             281

Dice Roll Solution 1

Dice Roll Solution 2




check back for more