Program Screen Shot:



Sample Output:


Program Code to Copy:
public class StringUtils {
public static void genGauge(String currentString)
{
System.out.println(currentString);
int c = 0;
int l =
currentString.length();
String genGauge = "";
while(c < l) {
genGauge =
genGauge + c;
if (c < 9)
{c++;}
else {c = 0; l =
l - 10;}
}
System.out.println(genGauge);
}
// returns a substring of currentString, including
startPosition, but ending before onePastLastPosition
public static String copy(String currentString, int
startPosition, int onePastLastPosition) {
return
currentString.substring(startPosition, onePastLastPosition);
}
// returns a String constructed by starting with
currentString, and removes the letters starting with
// startPosition and stopping before
onePastLastPosition
public static String cut(String currentString, int
startPosition, int onePastLastPosition) {
return
currentString.substring(0,startPosition) +
currentString.substring(onePastLastPosition,currentString.length());
}
// returns the String constructed by inserting
stringToInsert into currentString before position
insertBefore
public static String paste(String currentString, int
insertBefore, String stringToInsert) {
return
currentString.substring(0,insertBefore) + stringToInsert +
currentString.substring(insertBefore,currentString.length());
}
}
_______________________________________________________
import java.util.Scanner;
public class StringMangle {
public static void main(String[] args) {
Scanner input = new
Scanner(System.in);
// get string from
console/user
System.out.println("Enter a string:
");
String currentString =
input.next();
String clipboard = ""; //
initialize clipboard
int startPosition,
onePastLastPosition;
String choice; // menu option
// start sentinel-controlled
loop
do {
System.out.println("The current string is");
StringUtils.genGauge(currentString);
if(clipboard.length()>0)
System.out.println("The clipboard is \n"+ clipboard +" and it has a
length of "+clipboard.length());
System.out.println("Enter c to copy, x to cut, v to paste, q to
quit");
choice =
input.next().toLowerCase(); // convert to lower for easy comparison
in switch-case below
switch(choice)
{
case "c": //
copy
System.out.println("Enter the starting position
");
startPosition = input.nextInt();
System.out.println("Enter one past the ending
position ");
onePastLastPosition= input.nextInt();
clipboard = StringUtils.copy(currentString,
startPosition, onePastLastPosition);
break;
case "x": //
cut
System.out.println("Enter the starting position
");
startPosition = input.nextInt();
System.out.println("Enter one past the ending
position ");
onePastLastPosition= input.nextInt();
currentString = StringUtils.cut(currentString,
startPosition, onePastLastPosition);
break;
case "v": //
paste
System.out.println("Enter the position the paste
should come before ");
startPosition = input.nextInt();
currentString =
StringUtils.paste(currentString,startPosition,clipboard);
break;
case "q": //
will end sentinel-controlled loop
break;
default: //
unknown input
System.out.println("Invalid input");
break;
}
}while(!choice.equals("q")); //
loop again if choice is not q
}
}
------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,
IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~
JAVA, please help asap! Its due very soon and I cant figure it out StringUtils You...
Objectives By the end of this program, the student will have demonstrated the ability to Write static methods Use methods in a different class Write a sentinel-controlled loop Write nested if/else statements Manipulate Strings by character position StringUtils You are to complete the class StringUtils, which is in the attached zip file. Add the following public static methods: copy Write a method String copy(String currentString, int startPosition, int onePastLastPosition). This method returns a substring of currentString, including startPosition, but ending...
**IN JAVAAssignment 10.1 [95 points]The WordCruncher classWrite the Java code for the class WordCruncher. Include the following members:A default constructor that sets the instance variable 'word' to the string "default".A parameterized constructor that accepts one String object as a parameter and stores it in the instance variable. The String must consist only of letters: no whitespace, digits, or punctuation. If the String parameter does not consist only of letters, set the instance variable to "default" instead. (This restriction will make...
Need help with implementing a While, Do-while and for loops in a program. UML: - scnr : Scanner - rows : int - MAX_ASCII : int ------------------------------------------------------------------------------- + CharacterTables() : + CharacterTables(rows : int) : - getStartingValue() : int -displayTable(startValue : int) : void - userContinue() : boolean + main(args : String[]) : void In Section 5.10 we saw that there is a close relationship between char and int. Variables of type char store numbers. (Actually, variables of all types...
Breaking it Down Problem One problem that I find in new Java programmers is a tendency to put too much code in "main()". It is important to learn how to break a program down into methods and classes. To give you practice at this, I have a program that has too much code in main. Your job will be to restructure the code into appropriate methods to make it more readable. I will provide you with lots of coaching on...
Hi I need help with a java program that I need to create a Airline Reservation System I already finish it but it doesnt work can someone please help me I would be delighted it doesnt show the available seats when running the program and I need it to run until someone says no for booking a seat and if they want to cancel a seat it should ask the user to cancel a seat or continue booking also it...
cs55(java) please
Part 1: You are a programming intern at the student transfer counselor's office. Having heard you are taking CS 55, your boss has come to ask for your help with a task. Students often come to ask her whether their GPA is good enough to transfer to some college to study some major and she has to look up the GPA requirements for a school and its majors in a spreadsheet to answer their question. She would like...
Online shopping cart (continued) (Java) Hello, I need help with Java to figure this out. In my Shopping Cart Manager Class (Bottom Code), I get "Resource leak: 'sc' is never closed." I have tried multiple things and cannot figure it out. Thank you. Online shopping cart (continued) (Java) Hello, I need help with Java to figure this out. In my Shopping Cart Manager Class (Bottom Code), I get "Resource leak: 'sc' is never closed." I have tried multiple things and...
Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What This Assignment Is About? Classes (methods and attributes) • Objects Arrays of Primitive Values Arrays of Objects Recursion for and if Statements Selection Sort Use the following Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use upper case for constants. • Use title case (first letter is upper case) for classes. Use lower case with uppercase...
Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.) 2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...
Hello Guys. I need help with this its in java In this project you will implement a Java program that will print several shapes and patterns according to uses input. This program will allow the use to select the type (say, rectangle, triangle, or diamond), the size and the fill character for a shape. All operations will be performed based on the user input which will respond to a dynamic menu that will be presented. Specifically, the menu will guide...