Knowee
Questions
Features
Study Tools

Complete the code in the editor below. The variables , , and are already declared and initialized for you. You must:Declare variables: one of type int, one of type double, and one of type String.Read lines of input from stdin (according to the sequence given in the Input Format section below) and initialize your variables.Use the operator to perform the following operations:Print the sum of plus your int variable on a new line.Print the sum of plus your double variable to a scale of one decimal place on a new line.Concatenate with the string you read as input and print the result on a new line.Note: If you are using a language that doesn't support using for string concatenation (e.g.: C), you can just print one variable immediately following the other on the same line. The string provided in your editor must be printed first, immediately followed by the string you read as input.Input FormatThe first line contains an integer that you must sum with .The second line contains a double that you must sum with .The third line contains a string that you must concatenate with .Output FormatPrint the sum of both integers on the first line, the sum of both doubles (scaled to decimal place) on the second line, and then the two concatenated strings on the third line.

Question

Complete the code in the editor below. The variables , , and are already declared and initialized for you. You must:Declare variables: one of type int, one of type double, and one of type String.Read lines of input from stdin (according to the sequence given in the Input Format section below) and initialize your variables.Use the operator to perform the following operations:Print the sum of plus your int variable on a new line.Print the sum of plus your double variable to a scale of one decimal place on a new line.Concatenate with the string you read as input and print the result on a new line.Note: If you are using a language that doesn't support using for string concatenation (e.g.: C), you can just print one variable immediately following the other on the same line. The string provided in your editor must be printed first, immediately followed by the string you read as input.Input FormatThe first line contains an integer that you must sum with .The second line contains a double that you must sum with .The third line contains a string that you must concatenate with .Output FormatPrint the sum of both integers on the first line, the sum of both doubles (scaled to decimal place) on the second line, and then the two concatenated strings on the third line.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is the code that you need to complete:

import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        int i = 4;
        double d = 4.0;
        String s = "HackerRank ";

        Scanner scan = new Scanner(System.in);

        /* Declare second integer, double, and String variables. */
        int i2;
        double d2;
        String s2;

        /* Read and save an integer, double, and String to

This problem has been solved

Similar Questions

Your task is to take two numbers of int data type, two numbers of float data type as input and output their sum:Declare variables: two of type int and two of type float.Read lines of input from stdin (according to the sequence given in the 'Input Format' section below) and initialize your variables.Use the and operator to perform the following operations:Print the sum and difference of two int variable on a new line.Print the sum and difference of two float variable rounded to one decimal place on a new line.

n this challenge, you must read an integer, a double, and a String from stdin, then print the values according to the instructions in the Output Format section below. To make the problem a little easier, a portion of the code is provided for you in the editor.Note: We recommend completing Java Stdin and Stdout I before attempting this challenge.Input FormatThere are three lines of input:The first line contains an integer.The second line contains a double.The third line contains a String.Output FormatThere are three lines of output:On the first line, print String: followed by the unaltered String read from stdin.On the second line, print Double: followed by the unaltered double read from stdin.On the third line, print Int: followed by the unaltered integer read from stdin.To make the problem easier, a portion of the code is already provided in the editor.Note: If you use the nextLine() method immediately following the nextInt() method, recall that nextInt() reads integer tokens; because of this, the last newline character for that line of integer input is still queued in the input buffer and the next nextLine() will be reading the remainder of the integer line (which is empty).Sample Input423.1415Welcome to HackerRank's Java tutorials!Sample OutputString: Welcome to HackerRank's Java tutorials!Double: 3.1415Int: 42

InstructionsAssign the integer 10 to a variable named variable_1.Assign the float 2.5 to a variable named variable_2.Update the value of variable_1 by adding the float 6.5 to its current value. You can use the += operator.Update the value of variable_2 by multiplying its current value by the integer 2. You can use the *= operator.Display variable_1 and variable_2 using print().

18. int value = 453;19. int d1 = value % 10;20. int d2 = (value / 10) % 10;21. int d3 = (value / 100) % 10;22. System.out.println("" + d1 + d2 + d3);23. }24. }

Input FormatThere are three lines of input:The first line contains an integer.The second line contains a double.The third line contains a String.Output FormatThere are three lines of output:On the first line, print String: followed by the unaltered String read from stdin.On the second line, print Double: followed by the unaltered double read from stdin.On the third line, print Int: followed by the unaltered integer read from stdin.To make the problem easier, a portion of the code is already provided in the editor.Note: If you use the nextLine() method immediately following the nextInt() method, recall that nextInt() reads integer tokens; because of this, the last newline character for that line of integer input is still queued in the input buffer and the next nextLine() will be reading the remainder of the integer line (which is empty).Sample Input423.1415Welcome to HackerRank's Java tutorials!Sample OutputString: Welcome to HackerRank's Java tutorials!Double: 3.1415Int: 42

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.