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
Sveta_85 [38]
2 years ago
13

Write a program to enter a number and test if it is greater than 45.6.if the number entered is greater than 45.6 the program nee

ds to out the phrase Greater than 45.6
Computers and Technology
1 answer:
Elina [12.6K]2 years ago
4 0

Answer:

#include<stdio.h>                        //header file

int main()                                      //main function

{

float num;                                   // variable declaration

printf("Enter a number to test:\n");   // getting variable for test

scanf("%f", &num);

if (num>45.6)                                    //Testing weather greater or smaller

printf("\n %f is greater than 45.6", num);  // Result if greater

else

printf("\n %f is not greater than 45.6", num);  // Result if smaller or equal

return 0;

}

Explanation:

  • First of all , a variable will be declared in float (data type ).
  • User will input data in variable.
  • The variable will be compared using logical operator with 45.6
  • If it is greater, A phrase will be passed that number is greater than 45.6
  • Else if the number will not greater the phrase will say that the number is not greater than 45.6

You might be interested in
Write a program that asks the user to input a set of floating-point values. When the user enters a value that is not a number, g
Lady_Fox [76]

Answer:

Check the explanation

Explanation:

// include the necessary packages

import java.io.*;

import java.util.*;

// Declare a class

public class DataReader

{

// Start the main method.

public static void main(String[] args)

{

// create the object of scanner class.

Scanner scan = new Scanner(System.in);

// Declare variables.

boolean done = false;

boolean done1 = false;

float sum = 0;

double v;

int count = 0;

// start the while loop

while (!done1)

{

// start the do while loop

do

{

// prompt the user to enter the value.

System.out.println("Value:");

// start the try block

try

{

// input number

v = scan.nextDouble();

// calculate the sum

sum = (float) (sum + v);

}

// start the catch block

catch (Exception nfe)

{

// input a character variable(\n)

String ch = scan.nextLine();

// display the statement.

System.out.println(

"Input Error. Try again.");

// count the value.

count++;

break;

}

}

// end do while loop

while (!done);

// Check whether the value of count

// greater than 2 or not.

if (count >= 2)

{

// display the statement on console.

System.out.println("Sum: " + sum);

done1 = true;

}

}

}

}

Sample Output:

Value:

12

Value:

12

Value:

ten

Input Error. Try again.

Value:

5

Value:

nine

Input Error. Try again.

Sum: 29.0

3 0
3 years ago
Read 2 more answers
Assume that a gallon of paint covers about 350 square feet of wall space. Create anapplication with a main() method that prompts
Elena-2011 [213]

Answer:

import java.util.Scanner;

public class PaintClculator {

   public static void main(String[] args) {

Scanner in = new Scanner(System.in);

       System.out.println("Enter Values for length, width, and height of the room");

       double length = in.nextDouble();

       double width = in.nextDouble();

       double height = in.nextDouble();

       double wallArea = calculateWallArea(length,width,height);

       double noGallons = calculatePaint(wallArea);

       double price = price(noGallons);

       System.out.println("Price is: "+ price);

   }

   // Creating Method to Calculate Wall Area

   public static double calculateWallArea( double length, double width, double height){

       // formular for the surface area of a room Area=2*length*heigth+2*width*height+lenth*width

       double Area = 2*length*height+2*width*height+length*width;

       System.out.println("Wall Area: "+Area);

       return Area;

   }

   //Creating method to calculate amount of paint

   public static double calculatePaint(double Area){

       double noGallons = Area/350;

       System.out.println("Number of gallons: "+noGallons);

       return noGallons;

   }

   // Creating Method Calculate Price

   public static double price(double noGallons){

       return noGallons*32;

   }

}

Explanation

  1. Created Three Methods in all; calculateWallArea(), calculatePaint(), and price()
  2. Method calculateWallArea() calculates area based on this formula Area=2*length*heigth+2*width*height+lenth*width
  3. The value of Area is passed to method calculatePaint() Which calculates the number of gallons required to cover the area given that one gallon covers 350 wall space
  4. Method price() calculates and dis[plays the price by calling method calculatePaint() that returns number of gallons. since one gallon is 32$
3 0
3 years ago
What is cyber safety?
mario62 [17]

Answer: Cyber safety is a process that protects computers and networks. The cyber world is a dangerous place without security and protection.

Explanation: Hope this helps!

7 0
3 years ago
Talon is a new game designer working on an exciting and innovative game idea, but its time to examine the idea for technical fea
GarryVolchara [31]

Answer:

I think the answer is C.

Explanation:

4 0
2 years ago
Read 2 more answers
How do you keep word from trying to capitalize every isolated letter "i"
Firdavs [7]
Write "i" the write random words then delete it and add the lowercase i
8 0
2 years ago
Read 2 more answers
Other questions:
  • How to get an hdmi working from a chromebook?
    6·2 answers
  • Linguist study
    9·1 answer
  • Someone once observed that "the difference between roles and groups is that a user can shift into and out of roles, whereas that
    13·1 answer
  • Write a Twitter class that sets the Twitter user first (who is to be followed) and lets the client add up to 5 followers, which
    10·1 answer
  • ___ is a family of data formats that helps people automatically receive feeds anytime there are new postings to their favorite b
    14·1 answer
  • What is the data and information with example? ​
    9·1 answer
  • Technology changes rapidly. Do you think the development of new technology will slow down at some point? At some point will cons
    12·1 answer
  • The physical layer of the OSI model is not foundational to any of the other layers. True or False
    8·1 answer
  • What are some limitations when it comes to testing and ensuring program quality? List at
    15·1 answer
  • True or False: At the Company level, users will only have access to view projects to which they have been specifically granted a
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!