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
BartSMP [9]
4 years ago
3

Given 4 floating-point numbers. Use a string formatting expression with conversion specifiers to output their product and their

average as integers (rounded), then as floating-point numbers.
Computers and Technology
1 answer:
Vilka [71]4 years ago
4 0

Answer:

Java.

Explanation:

// float variables

float first_num, second_num, third_num, fourth_num;

first_num = 1.2f;,

second_num = 2.4f;

third_num = 3.1f;

fourth_num = 4.7f;

// Numbers product

float product_nums = first_num * second_num *third_num * fourth_num;

String.format("Product = %f"%n, product_nums);

// Numbers average (int and float)

int average_nums = (int) (first_num + second_num + third_num + fourth_num) / 4;

float average_nums_float = (first_num + second_num + third_num, + fourth_num) / 4;

String.format("Average  Int = %d%n", average_nums);

String.format("Average  float = %f%n", average_nums_float);

You might be interested in
What column, row, and text formatting issues are important when designing tables and lists?
MrRissso [65]

Answer:

Microsoft Excel or Google sheets.

Explanation:

7 0
4 years ago
Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with e
andrey2020 [161]

Answer:

This question has two parts, first part is about programming about a Player class and second for reading string from user and decide how many time duck string entered by user and terminate if user press goose string.

The explanation of both program (executable code) is given below in explanation section.

Explanation:

//Program 1

#include <iostream>

using namespace std;

int main()

{

 bool isPremiumCustomer;

 int nbooksPurchased;

 int totalBookPurchasedWithOffer;

// bool cutomerType;

 int freeBooks;

 cout<<"Press 1 for Premium Customer and 0 for regular Customer";

 cin>>isPremiumCustomer;

 cout<<"How many books you purchased ";

 cin>>nbooksPurchased;

 

 

switch(isPremiumCustomer)// what type of customer is  

{

case 1://if customer is premium

 if (nbooksPurchased >= 5&&nbooksPurchased<8)// purchase book greater between 5 and 8

  {

   freeBooks=1;//offer free book

   totalBookPurchasedWithOffer=nbooksPurchased+freeBooks;//total number of book including free book

   

   cout<<"You purchased total book with offer ";//show total books

   cout<<totalBookPurchasedWithOffer;

  }

   

  else if (nbooksPurchased >= 8)//if premium customer purchase more than 8 book

    {

    freeBooks=2;//offer two free book

    totalBookPurchasedWithOffer=nbooksPurchased+freeBooks;//total number of book including free book

    cout<<"You purchased total book with offer ";

    cout<<totalBookPurchasedWithOffer;//show total books

    }

  else{

   cout<<"You purchased total book with no offer ";

    cout<<nbooksPurchased;

   }

  break;

case 0:// if customer is regular customer

 if (nbooksPurchased >= 7&&nbooksPurchased<12)//and purchase book between 7 and 12

  {

   freeBooks=1;// offer 1 free book

   totalBookPurchasedWithOffer=nbooksPurchased+freeBooks;

   cout<<"You purchased total book with offer ";

   cout<<totalBookPurchasedWithOffer;

  }

   

  else if (nbooksPurchased >= 12)//if purchase 12 or more than 12 book

    {

    freeBooks=2;//offer two free book

    totalBookPurchasedWithOffer=nbooksPurchased+freeBooks;

    cout<<"You purchased total book with offer ";

    cout<<totalBookPurchasedWithOffer;

    }

 else{

  cout<<"You purchased total book with no offer ";

  cout<<nbooksPurchased;

  }

  break;

 

}

 

 

 

return 0;// terminate the program

 

}

/* program 1 has ended

and program 2 is started from here

#######################################################

*/

#include <iostream>

using namespace std;

int main()

{

string readstring;// take input string from user to enter either "goose" or "duck"

int count=0;//count the number of "duck"

while(readstring!="goose")//run loop, until user do not enter string  

{

 cout<<"Enter the string either goose or duck ";// prompt user to enter the string

 cin>> readstring;// read string from user

 if (readstring=="duck")//if string equal to "duck"

 {

  count=count+1;//count number of duck string enter by user

   

 }

}//exit/terminate the loop, if user enter the goose string

cout<< " Number of duck that were read " ;// show how many duck string entered by user

cout<<count;

return 0;// terminate the program

 

}

6 0
3 years ago
A farmer sells tomatoes. For some reason, the farm obeys mechanical laws of fate.
Mars2501 [29]

Answer:

Here are the if/elif statements:

if tomatoes == 24:  #if farmer sells exactly two dozen tomatoes

   watermelons +=4  #farmer receives 4 watermelons

elif tomatoes >= 12:  #else farmer sells at least a dozen tomatoes

   watermelons +=2  #farmer receives 2 watermelons

else:

   tomatoes<12   #On the days that farmer sells less than a dozen tomatoes

   apples +=1  #farmer will get a single apple

Explanation:

You can test the working of these if elif statements by this program:

tomatoes = int(input("Enter the amount of tomatoes sold: "))  #prompts user to enter number of tomatoes

watermelons = 0  #initialize watermelons value to 1

apples = 0  #initialize apples value to 1

if tomatoes == 24:

   watermelons +=4

elif tomatoes >= 12:

   watermelons +=2

else:  

   tomatoes<12

   apples +=1

   

print("Number of watermelons recieved: ",watermelons)  #displays the received number of watermelons

print("Number of apples recieved: ",apples )  #displays the received number of apples

8 0
3 years ago
This algorithm works by selecting the smallest unsorted item in the list and then swapping it with the item in the next position
Juliette [100K]

Answer:

a) Bubble sort

Explanation:

Bubble sort is a type of sorting algorithm that swaps small value with a bigger value over a number of rounds called pass.

5 0
3 years ago
A standard cd-rom is called a single-session disc. why are they called single-session discs?
katrin [286]
CD-ROM= Compact Disc- Read Only Memory (Can only be used once)
6 0
3 years ago
Other questions:
  • How do you think engel would feel about computers information systems and the internet?
    14·2 answers
  • Grace Hopper led the development of ______, a programming language for business applications.
    6·2 answers
  • MSSQL
    10·1 answer
  • Ignorance of policy is a legal excuse for an employee. TRUE or FALSE
    11·1 answer
  • How many feet are in 69 inches
    15·1 answer
  • A(n) ________ is a server-based operating system oriented to computer networking and may include directory services, network man
    5·1 answer
  • Free pass if you want it.
    12·2 answers
  • A _ is the acknowledgment of a potential noncomformity, or an opinion regarding an issue that is not covered by a standard
    6·1 answer
  • Please help me convert the numbers into binary
    14·1 answer
  • Data is stored on ________ using a laser to either melt the disc material or change the color of embedded dye.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!