I am stumped on one of my programs that has a lot of methods on it and the last one is one to print out only the upper case letters in a given input. Now I know converting to upper case is .touppercase or w/e BUT how do I print out from a given input?
As you can see I just have the method as a comment.
import java.util.*;
public class loopLab3
{
public static void main(String[] args)
{
//all of the methods that will be used, divided up so it is easier for me to read this way
incCount();
decCount();
evensCount();
loveJava();
promptJava();
//upperCase();
}
//counting and printing 1 - 10
public static void incCount()
{
//declaring the counter and the initial value
int count;
count = 1;
//while statement that keeps printing numbers until 10 is the last number printed
while (count != 11)
{
System.out.println(count);
count++;
}
}
// count and printing 10 - 1
public static void decCount()
{
//declaring counter and initial value
int deCount;
deCount = 10;
//while loop that gives a decremental value that reduces the number from 10 to 1 and doesnt go further
while (deCount != 0)
{
System.out.println(deCount);
deCount--;
}
}
//counts even numbers up to the number 20
public static void evensCount()
{
//declaring counter and initial value
int evenCount;
evenCount = 2;
//while loop that continues to count until it hits 20
while (evenCount != 21)
{
//if statement within while that prints even numbers only
if (evenCount % 2 == 0)
{
System.out.println(evenCount);
}
evenCount++;
}
}
//prints the statement 50 times
public static void loveJava()
{
//declares counter and initial value
int javaCount;
javaCount = 0;
//while loop that only prints 50 times
while (javaCount != 51)
{
System.out.println("I love java!");
javaCount++;
}
}
//prints statement user defined number of times
public static void promptJava()
{
//declares variables and input
int promptNum;
Scanner console = new Scanner(System.in);
System.out.println("Enter number of times you want to print");
promptNum = console.nextInt();
while (promptNum > 0)
{
System.out.println("I love java");
promptNum--;
}
}
}

New Topic/Question
Reply



MultiQuote








|