Question

OOLSVIEW 215710514 (ratected View) Wo CTED VIEW Beca 1. Write a program that reads in the radius and length of a cylinder and
hew)-Word (Product Activation Failed lernet can contain vinuses. Unless you need to edit its saler to stay in Protected View
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program1.java


import java.util.Scanner;

public class Program1 {
  
   public static void main(String args[]){
       Scanner sc = new Scanner(System.in);
      
       int length;
       double radius;
      
       System.out.print("Enter the radius and length of a cylinder: ");
       radius = sc.nextDouble();
       length = sc.nextInt();
      
       double area = Math.PI * radius * radius;
       System.out.println("The area is "+area);
       double volume = area * length;
       System.out.println("The Volume is "+volume);
   }

}


Program2.java


import java.util.Scanner;

public class Program2 {
  
   public static void main(String args[]){
       Scanner sc = new Scanner(System.in);
      
       System.out.format("%-10s%-30s%-10s\n", "ID","Description","Rate");
       System.out.format("%-10s%-30s%-10s\n", "K","Kabsa",13.5f);
       System.out.format("%-10s%-30s%-10s\n", "L","Laham Mandi",49f);
       System.out.format("%-10s%-30s%-10s\n", "M","Mazghut",17.5f);
       System.out.println();
      
       System.out.println("Enter your response: ");
      
       char response = sc.nextLine().charAt(0);
      
       if(response == 'k' || Character.toUpperCase(response) == 'K'){
           System.out.println("Your bill for Kabsa is ");
           System.out.println();
           System.out.println("KABSA - 13.5");
           System.out.println("VAT(5%) - "+13.5*0.05);
           System.out.println("---------------------------------");
           System.out.println("Total - "+(13.5+(13.5*0.05))+" SAR");
       }else if(response == 'l' || Character.toUpperCase(response) == 'L'){
           System.out.println("Your bill for Laham Mandi is ");
           System.out.println();
           System.out.println("LAHAM MANDI - 49");
           System.out.println("VAT(5%) - "+49*0.05);
           System.out.println("---------------------------------");
           System.out.println("Total - "+(49+(49*0.05))+" SAR");
       }else if(response == 'm' || Character.toUpperCase(response) == 'M'){
           System.out.println("Your bill for Mazghut is ");
           System.out.println();
           System.out.println("MAZGHUT - 17.5");
           System.out.println("VAT(5%) - "+17.5*0.05);
           System.out.println("---------------------------------");
           System.out.println("Total - "+(17.5+(17.5*0.05))+" SAR");
       }
      
   }

}

Add a comment
Know the answer?
Add Answer to:
OOLSVIEW 215710514 (ratected View) Wo CTED VIEW Beca 1. Write a program that reads in the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help me to write a program in C++ with comments and to keep it simple...

    Please help me to write a program in C++ with comments and to keep it simple as possible. Thank you! Here is my program I have done before and that need to be change: #include <iostream> #include <iomanip> using namespace std; // function prototype – returning one value double cylvol(double, double); // Note: two data types inside brackets double surfarea(double, double); // Note: two data types inside brackets int main() { double r, l, V, S; cout << setprecision(2) <<...

  • Need in C++ Assignment #1: Write a program to ask the user for a sphere radius...

    Need in C++ Assignment #1: Write a program to ask the user for a sphere radius r as a double. Then compute and display the sphere surface area using S-4*PI'r*r as double. Then compute and display the sphere volume using V-(1.33)*PIr'r*r as double. Use: const double PI-3.14;

  • iIn python please AutoSave H L04-3b Testing Lab - Protected View - Saved to this PC-...

    iIn python please AutoSave H L04-3b Testing Lab - Protected View - Saved to this PC- Search A [email protected] J 7 File Home Insert Draw Design Layout Share Comments References Mailings Review View Help Areas and Volumes We'll write a program that prompts the user for a radius and then prints: a) The area and circumference of a circle with that radius b) The volume and surface area of a sphere with that radius 1. To get started, what is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT