For String c = "hello world"; The Java statements int i c.indexOf ('o'); int j = c.indexOf('l'); will result in: O a.i = 4 and j = 9. O b.i = 5 and j= 9. Oc. i = 5 and j = 8. d.i = 4 and j = 8.
Q: A number (or a word) is called palindrome if it may be read in the same way from left to right as…
A: /* package codechef; // don't place package name! */ import java.util.*;import java.lang.*;import…
Q: class Output { public static void main(String args[]) { int x = 3.14; int y = (int) Math.abs(x);…
A: Given, We have to find the output of the given code. Code: class Output { public static void…
Q: One Computer Science program uses the following rules tor CS course placement: 1. if the CS AP score…
A: Objective: This program determines CS placement for students depending on certain given rules. The…
Q: In Java trace the table for the do while loop public class Main { public static void main(String[]…
A: According to the Question below the Solution:
Q: This questions is based on the program segment below: public class Text { public static void…
A: Define a class Text. Define main() function. Define and initialize two string variables txt1 and…
Q: Question 2: Write a Java program that prompts the user to enter an integer consisting of 3 digits,…
A: According to the Question below the Solution: Output:
Q: I need help with this question Write a Java program that prompts the user to enter a word then…
A: code:
Q: Suppose you have a real number variable x. Write a Java expression that computes the following value…
A: Given : Suppose you have a real number variable x. Write a Java expression that computes the…
Q: Write a program in java to check how many times punctuation is present in a string and you have to…
A: The punctuation marks used to write the sentences into pieces, clauses using some of the symbols are…
Q: 1. Write a Java program that prompts the user to enter a line of text and outputs the number of…
A: Take the input string. Calculate the uppercase letters. Calculate the lowercase letters. And…
Q: Program41.java Write a program that prompts the user to enter a full name consisting of three names…
A: ANSWER: Find Initial of name: Output:
Q: Suppose that height is a double variable and name is a string variable.What are the values of height…
A: Program code: //including necessary header files #include <iostream> //namespace standards…
Q: Write a program that prints a grocery receipt of items purchased.
A: EXPLANATION- Create main function . Declare seven variables with suitable names Initialize all the…
Q: Please help me in fixing the errors in this java program.
A: solution in below step
Q: Write a program that inserts parentheses, a space, and a dash into a string of 10 user-entered…
A: Unless the user specify a breaking condition inside the while loop, it will iterate - Ask the user…
Q: Scanner inputDevice = new Scanner(System.in); System.out.print("Enter an integer: "); int number =…
A: Java is an object-oriented programming language, it will be used to build web applications and also…
Q: ) The Bahraini Charity Club is conducting a fundraiser by selling chilli dinners to go. The price is…
A: PROGRAM INTRODUCTION: Import the required libraries. Start the definition of the main function.…
Q: The following code is in Java,find the error in the following: String[] names = { "George",…
A: The problem in 2 lines for (int i = 0; i < names.length(); i++) names.length will be used without…
Q: java method that receives two strings called s1 and s2 and then returns the number of rotations of…
A: Java is an object-oriented programming language, that is used to build web browser applications and…
Q: Write the java code body of the method countPunctuations. The method will return the number of…
A: The program is written in Java. Please find the source code and output in the following steps.
Q: Q Evaluate the following Java expression, if x-3, y=5, and z=10: ++z+y-y+ Z+X++
A: Prerequisite: ++x is a pre-increment operator. It first increments the variable value and then the…
Q: Write a Java program that asks the user to enter two Strings. Then, uses String method compareTo()…
A: String Comparison is done by comparing one character at a time from both the strings and whenever…
Q: Write a program that prompts the user to enter a full name consisting of three names (first middle…
A: The program is written in Java. Check the program screenshot for the correct indentation. Please…
Q: **This is programming with Java. Im a bit confused.. When answering if you could be kind enough to…
A: Answer: Our instruction is answer the first three part from the first part and I have done code…
Q: Output a half pyramid of stars with a height determined by the user. If the user enters a number…
A: Given: To write a java program to Output a half pyramid of stars with a height determined by the…
Q: In Java, int x = 2, y =1; The expression !(x >= y) is equivalent to the expression true . True…
A: Dear Student, Here it is given that x=2 and y =1, here x is definitely greater than y thus x>=y…
Q: Program61.java Write a program that prompts an employee to enter his/her hourly pay rate and hours…
A: According to Bartleby policy, I have provided program61.java in Step 2.
Q: In Java Find the value of x , y after the statements are executed: y=1; x=0; if (x>0) { if (2==2)…
A: if else is a conditional statement. If condition gets true then statement within if is executed…
Q: 1. Write a program in Java to calculate and print the Electricity Generator Bill, the user should…
A: As per the requirement program is completed in java. Algorithm: Step 1: Write the main() method Step…
Q: 2.1 Write a Java program that asks the user to enter their high school grade out of 4 as well as…
A: AND is true if both statements are True and OR is true if any of statements is True So, we can check…
Q: Q2. Write a java program that takes only an integer input between 1 and 26 prints a pyramid of…
A: Here I have created a string array to store all 26 English alphabets. Next, I have taken input from…
Q: * Question Completion Status: QUESTION TT There are five syntax errors in the following java…
A: ERRORS: Line 1: The statement should contain the name of the class but in the given line the name…
Q: Write a program in java language to Use String methods to write a program called TitleCase.java that…
A: Program to convert String from Lowercase to Uppercase public class toUppercaseString { public…
Q: Write a program that allows a user to enter three words, and display the appropriate three-letter…
A: A required Java program is as follows, File name: “Main.java” import java.util.*; public class Main…
Q: a. What is the output of executing the following Java statements: {5 int x = 10, y = 20; boolean bl…
A: The output for the program is given below Output - The value of b3 is false The value of b4 is…
Q: Please explain what kind of syntax errors or problems the following statements might have. 1 = x;…
A: Given: As per our policy, "Since you have asked multiple questions, we will solve the first question…
Q: In this java program. Please explain the output of the program. Thank youu Source Code: public…
A: Here, we are given a Java code and we are asked the output. I have run the code and attached the…
Q: Take two string from user and print 1 if the first string is greater than string 2 and 0 if both…
A: Required:- Take two strings from the user and print 1 if the first string is greater than string 2…
Q: Write a program in java to calculate the number of
A: Required: Write a program in java to calculate the number of vowels and constant from the string and…
Q: Question: (Code must be in java language) Assuming that you have the functions “drawPolygon(int[]…
A: As Describe above - No need to write the definition of the methods, there are no marks for…
Q: In java write a program that takes four int command-line arguments w, x, y, z,. define a boolean…
A: The java program and its approach are given below: - Approach: - Defining the main class and…
Q: Assume the following variables have been declared in a Java program: String first = "Park"; String…
A: Notes:- In substring(n):- It returns substring from 0 to n-1 In substring(start,end):- It returns…
Q: Program41.java Write a program that prompts the user to enter a full name consisting of three names…
A: AS PER OUR BARTLEBY ANSWERING GUIDELINES WE ARE ALLOWED TO ANSWER ONLY THE FIRST QUESTION POSTED BY…
Q: In Java: Forms often allow a user to enter an integer. Write a program that takes in a string…
A: Actually, the code has given below:
Q: Write a program that prompts the user to enter a number within the range of 1 through 10. The…
A: JAVA Code for above: import java.io.*;import java.util.Scanner; class Program { public static void…
Q: 1. Show the output of the following code. What is the output if x=3 and y - 2? What is the output if…
A: v
JAVA
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Java question Write a program that plays the Rock-Paper-Scissors game againstthe computer. When played between two people, each personpicks one of three options (usually shown by a hand gesture) atthe same time, and a winner is determined. In the game, Rockbeats Scissors, Scissors beats Paper, and Paper beats Rock. The program should randomly choose one of the three options (with-out revealing it), then prompt for the user's selection. At that point, the program reveals both choices and prints a statementindicating if the user won, the computer won, or if it was a tie.Continue playing until the user chooses to stop, then print thenumber of user wins, losses, and ties.CPSC 130: Introduction to Computer Programming I Program 3: Decisions In this programming assignment, you will implement two Java programs that deal with decisions. Part1: Determine correct quadrant for angle Complete the program below so that it prompts the user for an angle in degrees, and prints out the quadrant in which the angle is located, represented by Roman numerals, as shown in the following figure. 180⁰ II E III 90⁰ 270⁰ IV Notice that the value of the angle starts at zero degrees at the rightmost point of the circle, moving counterclockwise around the circle as the number of degrees grows. For instance, if the input angle has 100 degrees, it is in quadrant II, while an angle of 300 degrees is in quadrant IV and an angle of 45 degrees is in quadrant I. Each quadrant contains 90 degrees and starts at a multiple of 90. For example, 89 degrees is in quadrant I and 90 degrees is in quadrant II. All the input angle values must be integers between 0 and 359. If the value of an…The value of x at the end.int x = 1;x = x + 1;x++;
- JAVA PROGRAMMING LAB Write a Java program to takes 2 numbers from the user and print true if one or the other is teen, but not both. "teen" number is that number which lies in the range 13..19 inclusive.Questions #2: Assets Depreciation ProgramBusinesses fixed assets, such as buildings, equipment, machinery, and furniture, depreciate overthe years of usage.The yearly depreciation in value D for an asset is usually computed using the formula:D = (P – S) / Ywhere P is the asset purchase price in $, S is the salvage value in $, and Y is the number of yearsthe asset is used.Write a Java program, named A1_Q2, which:1. Display a welcome message.2. Prompts the user to enter the three values in the same order (i.e., P, S, and Y) as a singleinput separated by spaces between them.3. Computes the yearly depreciation in $, and yearly percentage depreciation, and numberof years the value gets depreciated to 50% of purchase price of the asset. Your programmust print the results in two decimal digits rounded.4. Display a farewell message, so that the user knows that the program has terminatednormally, example Thank you for using Asset depreciation tool.See you next time.True or false: Java variables cannot start with a capital letter.
- Assignment1 In this assignment you have to write a java program Assignment1 that contains all three zeros of the calculates the following third degree polynomial: 23 = -1 The solutions must be determined using the Newton-Raphson method. Work with an absolute accuracy of ɛ =0.00001. It means |x+1- X,] > ɛ Make sure your output looks like the Example output ( Like here below ). The real part and imaginary part must be rounded to three decimal places. The order of the zero points are not important. This order may be different for you. Example Output: PS C:\ Users\ Sam\Documents\Homework\PR> java Assignment1 Zero point 1 is equal to : -1.0 Zero point 2 is equal to : 0.5 - 0.866i Zero point 3 is equal to : 0.5 +0.866i Example Output for: f(z)= z³ +1int a = 9; int c = 6; int d = 6; boolean m; if (a==c && c != d) { m = true}; What is the value of m? True False 6 9Q4:What are the values of x and a after the following statements have been executed? a = 0; i = 1; x = 0; a = a + i; x = x +i/ a; a = a + i; x = x +i/ a; a = a + i; X = x +i/ a; a = a + i; x = x +i/ a; Q5: (a) Work out by hand the output of the following script for n=4: n = input( 'Number of terms? ); s = 0; for k = 1:n S = s+1/ (k *2); end; disp(sqrt(6 * s)) If you run this script for larger and larger values of n you will find that the output approaches a well-known limit. Can you figure out what it is? (b) Rewrite the script using vectors and array operations. 36 M.sc. Zena Ahmed 2016 MATLAB Section4 Q6:Work through the following script by hand. Draw up a table of the values of i, j and m to show how their values change while the script executes. Check your answers by running the script. v = [31 5]; i = 1; for j = v i=i+1; if i == 3 i=i+ 2; m = i+ j; end end
- def area(side1, side2): return side1 * side2s1 = 12s2 = 6 Identify the statements that correctly call the area function. Select ALL that apply. Question options: A print(f'The area is {area(s1,s2)}') B answer = area(s1,s2) C result = area(side1,side2) D area(s1,s2)Parking Charges Program in java Write a program that works out the amount a person has to pay for parking in a car park in a tourist town. If they say they are disabled, they are told it is free. Otherwise they enter the number of hours as a whole number (1-8) that they wish to park as well as whether they have an “I live locally” badge or are an old age pensioner both of which leads to a discount. The program tells them the cost to park. The calculation is done in this program as follows. If they are disabled it is free. Otherwise ... Take number of hours they wish to park and give a basic charge: • • • • 1 hour: 3.00 pounds 2-4 hours: 4.00 pounds 5-6 hours: 4.50 pounds 7-8 hours: 5.50 pounds Next modify the resulting charge based on whether they are local or not: • If local: subtract 1 pound If OAP: subtract 2 poundsYour program MUST include methods including ones that - asks for the hours and returns the basic charge. - asks whether they live locally /…Question # 2Assume the followingString s,t,h,a,n,e;int i;h = “Hello”;s = “How are you?”a = “abc”;n = null;e = “”;Give the values of the following expressions, or illegal1. h.length()2. h.substring(1)3. h.toUpperCase()4. h.toUpperCase().toLowerCase()5. h.indexOf("H")6. h.startsWith("ell")7. "Tomorrow".indexOf("o")8. "Tomorrow".indexOf("o", 3)9. "Tomorrow".lastIndexOf('o')10. "a = \"" + a + "\""11. (a.length() + a).startsWith("a")12. a.length() + a.startsWith("a")13. ">>>" + a.length() + a.startsWith("a")14. a.substring(1,3).equals("bc")15. a.substring(1,3) == "bc"16. "a".compareTo("c")17.…