Upper Lowercase

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Upper Lowercase as PDF for free.

More details

  • Words: 437
  • Pages: 3
UpperLowerCase /* * Filename: "UpperLowerCase.java" * Created by 1,000_naymes for ICt 352 * Purpose: to transform a string into all uppercase or all lowercase */ import javax.swing.JOptionPane; import java.util.Scanner;

// for GUIs // for formatting

public class UpperLowerCase { public static void main( String[] args ) { /************************************************************** declare and initialize variables **************************************************************/ String openingMessage = "This program will ask you for a string and then format it to all \n" + "uppercase or all lowercase.", menu, menu2, choiceMessage, choiceString, userString, userMessage = "Okay, please enter your string below: ", inputInputMessage, inputString,info, infoMessage, user, stringInputMessage, stringString, choice2Message, choice2String; int choice, choice2; JOptionPane.showMessageDialog( null, openingMessage ); /************************************************************** input **************************************************************/ menu = "Please enter \n" + "1 to enter a string\n" + "2 to transform your string to all uppercase\n" + "3 to transform your string to all lowercase\n" + "4 to quit. "; choiceString = JOptionPane.showInputDialog( menu ); choice = Integer.parseInt( choiceString ); //converting string to integer do { switch( choice ) { case 1: /************************************************************** input string **************************************************************/ choice2Message = "Please enter\n" + "2 to transform your string to all uppercase or \n" + "3 to transform your string to all lowercase. \n"; choice2String = JOptionPane.showInputDialog( choice2Message ); choice2 = Integer.parseInt( choice2String ); switch( choice2 ) { case 2: /************************************************************** transform to all uppercase **************************************************************/ userString = JOptionPane.showInputDialog( userMessage ); user = (userString); Page 1

UpperLowerCase info = user.toUpperCase(); infoMessage = "You entered '"+ info + "'"; JOptionPane.showMessageDialog( null, infoMessage); choiceString = JOptionPane.showInputDialog( menu ); choice = Integer.parseInt( choiceString ); //converting string to integer if( choice == 4) System.exit(0); break; case 3: /************************************************************** transform to all lowercase **************************************************************/ userString = JOptionPane.showInputDialog( userMessage ); user = (userString); info = user.toLowerCase(); infoMessage = "You entered '"+ info + "'"; JOptionPane.showMessageDialog( null, infoMessage ); choiceString = JOptionPane.showInputDialog( menu ); choice = Integer.parseInt( choiceString ); //converting string to integer if( choice == 4) System.exit(0); break; } // end switch( choice2 ) case 2: /************************************************************** transform to all uppercase **************************************************************/ userString = JOptionPane.showInputDialog( userMessage ); user = (userString); info = user.toUpperCase(); infoMessage = "You entered '"+ info + "'"; JOptionPane.showMessageDialog( null, infoMessage); choiceString = JOptionPane.showInputDialog( menu ); choice = Integer.parseInt( choiceString ); //converting string to integer if( choice == 4) System.exit(0); break; case 3: /************************************************************** transform to all lowercase **************************************************************/ userString = JOptionPane.showInputDialog( userMessage ); user = (userString); info = user.toLowerCase(); infoMessage = "You entered '"+ info + "'"; JOptionPane.showMessageDialog( null, infoMessage ); choiceString = JOptionPane.showInputDialog( menu ); choice = Integer.parseInt( choiceString ); //converting string to integer if( choice == 4) Page 2

UpperLowerCase System.exit(0); break; case 4: /************************************************************** quit **************************************************************/ System.exit(0); } } while(choice != 4); System.exit(0); } }

Page 3

Related Documents

Upper Lowercase
November 2019 13
Upper Extremity
April 2020 8
Upper 6
May 2020 5
Upper Limb
June 2020 9