- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
1.Which of the expressions below is true if and only if an array A containing three different integers is sorted in ascending order a. A[1] < A[2] || A[2] < A[3] b. A[0] < A[1] && A[1] < A[2] c. A[0] < A[1] || A[1] < A[2] d. A[1] < … | |
public static void sumOfSquareRoots() { Scanner scan = new Scanner( System.in ); double value; // read in a double System.out.print ("Enter a double:"); value = scan.nextDouble(); // calculate its square root double result = Math.sqrt( value ); // write out the result System.out.println("square root of your number is " + … | |
public static void total() { Scanner s = new Scanner("five six seven eight"); int num= 0; for(int i=0; i < s.length; i++) { if(s.charAt(i).equals("a") || s.charAt(i).equals("b") num++; } System.out.print(num); } public static void main(String[] args) { total(); } > What am I doing wrong ? | |
import java.util.Scanner; public class LoopPatterns { /** * @param args */ public static void main(String[] args) { public static double Largest { Scanner s = new Scanner(System.in); int num, largest = 0; for ( int i = 1; i <= 10 ;i ++) { System.out.print("Enter a number : "); num … | |
import java.util.Scanner; public class LoopPatterns { /** * @param args */ public static double Largest (){ Scanner s = new Scanner(System.in); int num, largest = 0; for ( int i = 1; i <= 10 ;i ++) { System.out.print("Enter a number : "); num = s.nextInt(); if ( num > … | |
> I am supposed to create a method called compareParity which compareParity that takes a Scanner containing words as its parameter. The method should return true if the Scanner contains more strings of even length than strings of odd length, and false otherwise. For example, compareParity(new Scanner("The quick brown fox … | |
1.Suppose a method is declared as: public static void f (double d, int n) { ....; } Which one of the follow method invocations would compile with no errors? Select one: a. f(2.5, 3.5); b. f(2, 3); c. f(2.5); d. f(3); I chose b 2.Each of the following pieces of … | |
public static void drawIndentedLine (int spaces, String begin, int n, String middle, String end) It should print a single line, terminated with a newline, that begins with the specified number of spaces, followed by the begin string, followed by n copies of the middle string, followed by the end string. … | |
package cs1410; import javax.swing.*; public class P2 { public static void main(String []args) { drawDiamond(); } public static void drawDiamond() { int x,y,z; int a=1; String out="\n"; int i=Integer.parseInt(JOptionPane.showInputDialog("Enter your size")); if((i%2)!=0) { int in=(i/2)+(i%2); int bb=in-1; int b=bb+(bb-1); for(x=in;x>0;x--) { for(y=x;y>1;y--) out+=" "; for(z=0;z<a;z++) out+="*"; a+=2; out+="\n"; } for(x=0;x<in-1;x++) … | |
I am supposed to use this method public static void drawIndentedLine (int spaces, String begin, int n, String middle, String end) This is what I am suppsed to do **It should print a single line, terminated with a newline, that begins with the specified number of spaces, followed by the … | |
Hi I am just starting to learn about java.I am trying to calculate BMI of an individual using the JOptionPane.showInputDialog method who I am asking to enter 4 things first name,last name,height in inches and weight in pounds. I want to show the BMI using JOptionPane.showMessageDialog method showing their full … |