192k views
3 votes
I'm not sure how to do these.

I'm not sure how to do these.-example-1
User Olrac
by
5.1k points

1 Answer

1 vote

Answer:

JAVA

TASK 1

float float75 = 75; # widening casting are done automatically.

String string75 = String.valueOf(75);

float75 + string75 = Error: As the compiler doesn't know how to approach this, are you trying to add float to unicode charcters, if there is a value in this string, CAST it out, EXORCISE

TASK 2

import java.util.Scanner;

class MyClass {

public static void main(String[] args) {

Scanner myObj = new Scanner(System.in); // Create a Scanner object

System.out.println("Enter Float number");

float number = myObj.nextFloat();

System.out.println(number ** 2);

TASK 3

import java.util.Scanner;

class MyClass {

public static void main(String[] args) {

Scanner myObj = new Scanner(System.in); // Create a Scanner object

System.out.println("Enter number");

int number = myObj.nextInt();

int quotient = number / 7;

int reminder = number % 7;

System.out.printf("When you divide %d by 7, the quotient is %d and the reminder is %d ", number, quotient, reminder);

TASK 4

import java.util.Scanner;

class MyClass {

public static void main(String[] args) {

Scanner myObj = new Scanner(System.in); // Create a Scanner object

System.out.println("How many gigabytes is your flash drive");

int gigabytes = myObj.nextInt();

long numBits = gigabytes * 8000000000

System.out.printf("Number of bits in your %d flashdrive: %ld Bits", gigabytes, numBits);

User Mitul Nakum
by
4.8k points