Question One
Write a menu driven program with functions to calculate the volume of the given shapes. The volume should be displayed using a separate function.
a) Sphere: (pass arguments by value)
=
b) Cylinder: (pass arguments by reference)
=
c) Cube: (pass arguments by value)
=
Question Two
The table shows the average rainfall and temperature during the past rain season stored in a text file called Weather.txt
Town
Temperature
Rainfall Chingola 23 27
Kitwe
24
27 Ndola 23 26
Kabwe
24
26 Lusaka 22 26
Kafue
24
16 Mazabuka 26 15
Monze
26
12 Choma 27 10
Livingstone
26
10
2
Write a program that reads this information from the text file, stores the values in parallel
arrays and prints the information stored in the arrays to the screen.
Answers
Answer:the two answers are as follows
Explanation:
Assuming all necessary header files are declared and required integers are given.
1) cout<<"enter the option
option 1: sphere
option 2: cylinder
option 3: sphere
";
cin>>p;
switch(p)
{
case 1: cout<<" enter radus";
cin>>r;
vol= 4/3*(22/7)*r*r*r
break;
case 2: cout<< "enter height";
cin>>h;
vol=(22/7)*r*r*h
case 3: cout<<" Enter side ";
break;
cin>>a
vol=pow(a,3)
break;
case 4: exit (0) ;
}
2)please kindly specify the table properly.
I'm showing the array part.
for(i=0;i<n;i++)
{
cout<<arr[i];
}
n will be then no of files(.txt) entries allowed and arr Index will show the file content after taking them in the file system
Answer:
Q1.
import java.util.Scanner;
class Volume
{
public static void main (String args [ ])
{
System.out.println ("Volume Calculation Menu");
System.out.println ("-------------------------------------");
System.out.println ("a) Sphere");
System.out.println ("b) Cylinder");
System.out.println (c) Cube");
System.out.println ("Choose from a to c");
#Rest copy from the other answer