1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alex41 [277]
3 years ago
14

Give the type and value of each result of the following Java expressions.

Computers and Technology
1 answer:
atroni [7]3 years ago
3 0
Give the type and value of each result of the following Java expressions. a. (5 / 2) * 2.0  type is float value is 4.0 b. (5/2.0) * 2 type is integer value is 5c. "1.3" + "5.2" type is string value is 1.35.2d. 1 + 7.0 + "2" + "x"  this will produce an error because we cannot add variables of different type
You might be interested in
Consider the class Money declared below. Write the member functions declared below and the definition of the overloaded +. Modif
disa [49]

Answer: Provided in the explanation section

Explanation:

#include<iostream>

using namespace std;

class Money{

  private:

      int all_cents;

  public:

      Money();

      double get_value() const;

      Money(int,int);

      void printamount();

      friend Money operator+(const Money&, const Money&);

      friend ostream& operator<<(ostream&, const Money&);

      friend istream& operator>>(istream&, Money&);

};

Money::Money(){all_cents=0;}

double Money::get_value() const{return all_cents/100.0;}

Money::Money(int dollar ,int cents){

  all_cents = dollar*100+cents;

}

void Money::printamount(){

  cout<<"$"<<get_value()<<endl;

}

Money operator+(const Money& m1, const Money& m2){

  int total_cents = m1.all_cents + m2.all_cents;

  int dollars = total_cents/100;

  total_cents %=100;

  return Money(dollars,total_cents);

}

ostream& operator<<(ostream& out, const Money& m1){

  out<<"$"<<m1.get_value()<<endl;

  return out;

}

istream& operator>>(istream& input, Money& m1){

  input>>m1.all_cents;

  return input;

}

int main(){

 

  Money m1;

  cout<<"Enter total cents: ";

  cin>>m1;

  cout<<"Total Amount: "<<m1;

 

  Money m2 = Money(5,60);

  Money m3 = Money(4,60);

  cout<<"m2 = ";m2.printamount();

  cout<<"m3 = ";m3.printamount();

  Money sum = m2+m3;

  cout<<"sum = "<<sum;

 

}

cheers i hope this helped !!

5 0
3 years ago
24 bit or 16 million colors is often called?
galben [10]
Is it bit-depth maybe????
7 0
3 years ago
Which of the following might cause a shift from PPF1 to PPF2? I. A new source of high quality denim fabric. II. A new lighter me
topjm [15]

fAnswer:  A new source of high quality denim fabric

Explanation:

A shift from PPF1 to PPF2 would suggest a new improvement due to technology, innovation or raw material. Here a new source of high quality fabric would result in more and better production of fabrics.

3 0
3 years ago
Please answer this question​
prisoha [69]

Answer:surfing, printer

Explanation:

5 0
3 years ago
HELP PLZZ WILL MARK BRAINLIEST
adoni [48]

Answer:

if you could capture another image of this work bc I cant make out some words I can barley make out words

4 0
3 years ago
Other questions:
  • Which data type uses more memory an integer or an unsigned integer?
    6·1 answer
  • . Reorder the following efficiencies from smallest to largest:
    9·1 answer
  • What is an effective way to display calculations in a Word document
    7·2 answers
  • Write a function, sublist, that takes in a list of numbers as the parameter. In the function, use a while loop to return a subli
    13·1 answer
  • 25 Points Discuss games you have played that have poor game design puzzles and how you might improve them.
    10·1 answer
  • The domain name service (dns is a distributed database that allows users to communicate with each other computers by:
    7·1 answer
  • Select the correct answer.
    10·2 answers
  • Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cre
    11·1 answer
  • What is the language of computers?
    9·1 answer
  • What product use programmable control?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!