PRG/420: Java Programming - 4 LABS

(LAB 1) Count input length without spaces, periods, or commas
 
Given a line of text as input, output the number of characters excluding spaces, periods, or commas.
Ex: If the input is:
Listen, Mr. Jones, calm down.

the output is:
21

Note: Account for all characters that aren't spaces, periods, or commas (Ex: "r", "2", "!").

 
(LAB 2) LAB: Output range with increment of 10
 
Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer.
Ex: If the input is:
-15 30

the output is:
-15 -5 5 15 25

Ex: If the second integer is less than the first as in:
20 5

the output is:
Second integer can't be less than the first.

For coding simplicity, output a space after every integer, including the last.

 
(LAB 3) Print string in reverse
 
Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text.
Ex: If the input is:
Hello there
Hey
quit

the output is:
ereht olleH
yeH

 
(LAB 4) Palindrome
 
A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.
Ex: If the input is:
bob

the output is:
bob is a palindrome

Ex: If the input is:
bobby

the output is:
bobby is not a palindrome

Hint: Start by just handling single-word input, and submit for grading. Once passing single-word test cases, extend the program to handle phrases. If the input is a phrase, remove or ignore spaces.
  1. Question Attachments

    4 attachments —

Answer Detail

Get This Answer

Invite Tutor