Question

please write me in java 5 points: Print your name using Java. 10 points: Do some...

please write me in java

5 points: Print your name using Java.

10 points: Do some math with doubles

15 points: Use a scanner.

20 points: read in some ints and do math with doubles.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
class Main {
public static void main(String[] args) {
System.out.println("John Nash"); // pur your name here
}
}
Output: John Nash
class Main {
public static void main(String[] args) {
// declaring variables
double a = 1.5;
double b = 2.5;
  
// performing addition operation
double c = a+b;
  
// printing output
System.out.println(c);
}
}
Output: 4.0
import java.util.Scanner;
class Main {
public static void main(String[] args) {
// declaring a scanner variable
Scanner sc = new Scanner(System.in);
  
// Prompting for user input
System.out.print("Enter a number: ");
  
// taking user input
int a = sc.nextInt();
  
// printing output
System.out.println("You entered "+a);
}
}

Sample Output

Enter a number:  9
You entered 9
import java.util.Scanner;
class Main {
public static void main(String[] args) {
// declaring a scanner variable
Scanner sc = new Scanner(System.in);
  
// Prompting for user input
System.out.print("Enter a number: ");
int intc = sc.nextInt();
  
System.out.print("Enter a number: ");
int intd = sc.nextInt();
  
// declaring variables
double a = 1.5;
double b = 2.0;
  
// performing addition operation
double c = a+b+intc+intd;
  
// printing output
System.out.println(c);
}
}

SAMPLE OUTPUT

Enter a number:  2
Enter a number:  3
8.5
Add a comment
Know the answer?
Add Answer to:
please write me in java 5 points: Print your name using Java. 10 points: Do some...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Would you please do Pseudocode for this progarm in Java?? Using scanner algorithm, The scanner takes...

    Would you please do Pseudocode for this progarm in Java?? Using scanner algorithm, The scanner takes the name of a text file from the command line and prints out the list of tokens. If there is non-valid token in the input file, print out “error”. please help me to write Pseudocode! thank you!! The scanner takes the name of a text file from the command line. It outputs to the console error if there is any non-valid token in the...

  • in Java and also follow rubric please 4. Write a complete program to do the following:...

    in Java and also follow rubric please 4. Write a complete program to do the following: Using an input and output files, write a program that will read 20 numbers from an input file called InFile. Sum all even numbers and multiply all odd numbers. Print the numbers read from the input file to an output file called OutFile. Also print the sum of the even numbers and the product of the odd numbers to the output file. Rubric: •...

  • Could you guys write an efficient java program to implement BST. Your java program should read...

    Could you guys write an efficient java program to implement BST. Your java program should read words and its corresponding French and store it in a BST. Then read every English word and print its corresponding French by searching in BST. Assume your java program is in xxxxx5.java file (5th java project), where xxxxx is the first 5 characters of your last name. To compile: javac xxxxx5.java To execute: java xxxxx5 < any data file name Your main method should...

  • This is java. Please let me know about those code. Please do not use array and...

    This is java. Please let me know about those code. Please do not use array and scanner. Just do by loop. // a) Task: Find the sum of all multiples of 3 and 5 less than 1000. // b) Task: Given two integers k and n, print out every multiple of k less than n // c) Task: Given an integer n, print out k^k for every k=1...n // d) Task: Write a function called "factorProduct" that takes as input...

  • Write a java program to convert and print an infix expression to postfix expression. You can...

    Write a java program to convert and print an infix expression to postfix expression. You can use Java stack methods. (Must read input from System.in) Your main method should be as follow: public static void main(String args[]) { intopost p = new intopost (); String iexp, pexp; //infix postfix expression             try{ Scanner inf = new Scanner (System.in);                     // Read input from KB/ File while(inf.hasNext()){ // read next infix expression                                 iexp = inf.next(); // Assume method name to convert infix...

  • specs for ComputeAverage ComputeAverage Write a class called ComputeAverage what it does: asks the user to...

    specs for ComputeAverage ComputeAverage Write a class called ComputeAverage what it does: asks the user to enter three double numbers (see examples below), it uses Scanner class to read from standard input each one of the doubles entered by the user. it then prints the average of the three numbers. Suggested steps: 1. prompt the user to enter each of the three doubles by printing. 2. read each of the three doubles using a Scanner. Remember you need to declare...

  • PLEASE READ THE FULL INSTRUCTION. Write a Java programme to print the pattern of asterisks shown...

    PLEASE READ THE FULL INSTRUCTION. Write a Java programme to print the pattern of asterisks shown below. For i=1 For i=2 * * For i=3 For i=n ** * ** ** ......... * (n asterisks) Your program should prompt the user to enter the value of n and then draw the corresponding star pattern. Remember if n is 5, you will have to print five patterns for i=1, i=2, i=3, i=4, and i=5. If n is 3, you will have...

  • We are using blueJ for my java class, if you can help me id greatly appreciate...

    We are using blueJ for my java class, if you can help me id greatly appreciate it. Create a new Java class called AverageWeight. Create two arrays: an array to hold 3 different names and an array to hold their weights. Use Scanner to prompt for their name and weight and store in correct array. Compute and print the average of the weights entered using printf command. Use a loop to traverse and print the elements of each array or...

  • Write a program in Java to implement the max-priority queue using max-heap data structure. Implement the...

    Write a program in Java to implement the max-priority queue using max-heap data structure. Implement the max-heap data structure using an integer array of 10 cells. (Do not use Java in-built PriorityQueue class.) [In a max-heap, the root node and the intermediate node vales are always greater than their children.] First, take 10 integer values from the user and insert them in the max-priority queue. Then print the elements of the queue. After that, delete two elements from the queue...

  • please help me with, Write a program in java that generates 10 random doubles, all between...

    please help me with, Write a program in java that generates 10 random doubles, all between 1 and 11, and writes them to a text file, one number per line. Then write another program that reads the text file and displays all the doubles and their sum accurate to two decimal places. SAMPLE OUTPUT 10.6269119604172 2.737790338909455 5.427925738865128 1.3742058065472509 1.1858700262498836 4.180391276485228 4.910969998930675 5.710858234343958 7.790857007373052 3.1806714736219543 The total is 47.13

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT