


i need help getting this program running
Explanation::
Code in JAVA::
import java.util.Scanner;
public class Methods {
public static void main(String[] args) {
/**
* Declaring Scanner class object
named kb
* */
Scanner kb = new
Scanner(System.in);
/**
* Calling the run() method
* */
run(kb);
kb.close();
}
public static void run(Scanner kb) {
/**
* An integer variable named n is
declared and we will store how many
* times this program needs to be
run as per user input
* */
int n;
System.out.print("How many times do
you want to run this program? ");
n = kb.nextInt();
/**
* Running for loop for n
times
* */
for(int i=1;i<=n;i++) {
/**
* An String
variable named option is declared
* and we call
the getOption() method
* */
String option =
getOption(kb);
if(option.equals("sentence analyzer")) {
String sentence;
kb.nextLine();
System.out.print("\nEnter the sentence:
");
sentence = kb.nextLine();
String answer =
sentenceAnalyser(sentence);
System.out.println("The given sentence is an
"+answer+".");
}else
if(option.equals("probable season")) {
double temp;
System.out.print("\nEnter the temperature in
degree Fahenheit: ");
temp = kb.nextDouble();
String answer = probableSeason(temp);
System.out.println("The probable season is
"+answer);
}
System.out.println();
}
}
public static String getOption(Scanner kb) {
int choice;
System.out.println("\nChoose any
one from below");
System.out.println("Enter 1 for
Problem 1");
System.out.println("Enter 2 for
Problem 2");
System.out.print("Enter: ");
choice = kb.nextInt();
if(choice==1) {
return "sentence
analyzer";
}else if(choice==2) {
return "probable
season";
}
return "unknown choice";
}
public static String sentenceAnalyser(String sentence)
{
/**
* integer variable length will
store length of the string sentence
* */
int length =
sentence.length();
/**
* An char variable named lastChar
will store last character of sentence string
* */
char lastChar =
sentence.charAt(length-1);
if(lastChar=='.') {
return
"declarative";
}else if(lastChar=='?') {
return
"interrogative";
}else if(lastChar=='!') {
return
"exclamatory";
}
return "unknown sentence
type";
}
public static String probableSeason(double temp)
{
if(temp>110 || temp<-5)
{
return
null;
}
if(temp>=90) {
return
"summer";
}else if(temp>=70 &&
temp<90) {
return
"spring";
}else if(temp>=50 &&
temp<70) {
return
"fall";
}else {
return
"winter";
}
}
}
OUTPUT:
How many times do you want to run this program? 7
Choose any one from below
Enter 1 for Problem 1
Enter 2 for Problem 2
Enter: 1
Enter the sentence: Hello World!
The given sentence is an exclamatory.
Choose any one from below
Enter 1 for Problem 1
Enter 2 for Problem 2
Enter: 2
Enter the temperature in degree Fahenheit: 45.78
The probable season is winter
Choose any one from below
Enter 1 for Problem 1
Enter 2 for Problem 2
Enter: 2
Enter the temperature in degree Fahenheit: -10
The probable season is null
Choose any one from below
Enter 1 for Problem 1
Enter 2 for Problem 2
Enter: 1
Enter the sentence: Are you ok?
The given sentence is an interrogative.
Choose any one from below
Enter 1 for Problem 1
Enter 2 for Problem 2
Enter: 1
Enter the sentence: We are dominant on earth.
The given sentence is an declarative.
Choose any one from below
Enter 1 for Problem 1
Enter 2 for Problem 2
Enter: 1
Enter the sentence: well done
The given sentence is an unknown sentence type.
Choose any one from below
Enter 1 for Problem 1
Enter 2 for Problem 2
Enter: 2
Enter the temperature in degree Fahenheit: 90
The probable season is summer
Please provide the feedback!!
Thank You!!
i need help getting this program running Pearson Sign in Mail - Josue Velazq... CSC 15...
Problem 14: all 5 parts must be complete to receive credit for the question /** * q1: Write a public static method named q1 that takes no parameters and returns void. The * method should print all the integers from -8 to 47 to the screen. The output should be * inclusive of these end points */ /** * q2: Write a public static method named q2 that takes two ints as parameters and returns...
I need help with my Java code. A user enters a sentence and the program will tell you what words were duplicated and how many times. If the same word is in the sentence twice, but one is capitalized, it will not count it as a duplicate. How can I make the program read the same word as the same word, even if one is capitalized and the other is not? For example, "the" and "The" should be counted as...
File Factorials.java contains a program that calls the factorial method of the MathUtils class to compute the factorials of integers entered by the user. In this program, two things can possibly occur: The program always returns 1 if negative integers are entered by the user. Returning 1 as the factorial of any negative integer is not correct. The program also returns negative numbers when the user enters integers greater than 16. Returning a negative number for values over 16 also...
I need to create a code for this prompt: In this project we will build a generic UserInput class for getting keyboard input from the user. Implementation: The class UserInput is a 'Methods only' class, and all the methods should be declared static. Look at the TestScanner.java program at the bottom of this page that inputs a string, int and double. It shows you how to use Scanner class to get input from the keyboard. Write FOUR simple methods, one...
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...
/* * CPS150_Lab10.java */ import java.io.*; import java.util.*; /** * CPS 150, Fall 2018 semester * * Section N1 * * Lab Project 13: Comparing Java Strings * * @author *** Replace with your name *** */ public class CPS150_Lab13 { static final Scanner KBD = new Scanner(System.in); static final PrintStream OUT = System.out; // TO DO: Implement each of the following 4 methods, // using the String compareTo method: /* * lessThan(String, String) -> boolean * * method is...
Complete the printPalindrome method in the provided Palindrome.java program. The printPalindrome method accepts a String as a parameter and prints whether the parameter String is a palindrome (i.e., reads the same forwards as it does backwards, for example, "abba" or "racecar"). Make the code case-insensitive, so that words like "Abba" and "Madam" will be considered palindromes. import java.util.*; /** * Determines if a user entered String is a palindrome, which means the String * is the same forward and reverse....
******** IN JAVA ********* I have a program that I need help debugging. This program should ask a user to input 3 dimensions of a rectangular block (length, width, and height), and then perform a volume and surface area calculation and display the results of both. It should only be done using local variables via methods and should have 4 methods: getInput, volBlock, saBlock, and display (should be void). I have most of it written here: import java.util.*; public class...
need help editing or rewriting java code, I have this program
running that creates random numbers and finds min, max, median ect.
from a group of numbers,array. I need to use a data class and a
constructor to run the code instead of how I have it written right
now. this is an example of what i'm being asked
for.
This is my code:
import java.util.Random;
import java.util.Scanner;
public class RandomArray {
// method to find the minimum number in...
I need help debugging this Java program. I am getting this error message: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at population.Population.main(Population.java:85) I am not able to run this program. ------------------------------------------------------------------- import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; /* Linked list node*/ class node { long data; long year; String country; node next; node(String c,long y,long d) { country=c; year=y; data = d; next = null; } } public class Population { private static node head; public static void push(String...