Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Daniel on 4/20/2016.
- */
- 20.
- it prints all the letters in a range of two letters
- efg
- nopqrs
- qr
- 21.
- String s = [words]
- char s = s.charAt(0);
- if(isUpperCase(c)){
- //statements
- }
- 22.
- It uses the incorrect syntax of s.charAt(i).toLowerCase(), when it should be:
- Character.toLowerCase(s.charAt(i))
- 24.
- /**
- * Created by Daniel on 4/20/2016.
- */
- //create a code to examine astring and determine how many of its letters come from the second half of the alhabet
- // have values of 'n' or subsequent letters, assume every character in a string is a letter, case intensively
- import java.util.*;
- public class selfCheck24 {
- public static void main(String[] args) {
- Scanner c = new Scanner(System.in);
- v(c);
- }
- public static void v(Scanner c) {
- System.out.print("Enter a string:");
- String s = c.next();
- int count = 0;
- for (int i = 0; i < s.length(); i++) {
- if (Character.toLowerCase(s.charAt(i)) >= 'n') {
- count++;
- }
- }
- System.out.printf("total count %d",count);
- }
- }
- 26.
- In the parameters of the method one must enter the grade percentage value
- so that later in the method it can convert the previously gien values to a value between 0.0-4.0
- 28.
- modified version to work in the situation that a != 0... because if a = 0 then you would not be using a quadratic.
- public static String quadratic(int a, int b, int c){
- String answer = "Error, [int a] must not be equal to zero";
- if(a != 0){
- double xplus = (b*-1 + Math.sqrt((b*b)-(4*a*c)*1.0)) / 2*a ;
- double xminus = (b*-1 - (Math.sqrt((b*b)-(4*a*c)*1.0)) ) / 2*a ;
- answer = "x = " + (int)xplus + "," + "x = " + (int)xminus;
- }
- return answer;
- }
- //In this new version, the program returns an error message if a equals 0.
Advertisement
Add Comment
Please, Sign In to add comment