Add statements to this program so that it computes the circumference....

How do I add statements to this program so that it computes the circumference in addition to the area for both circles?
// Circle.java
// Print the area of a circle with two different radii
import java.util.Scanner;
public class circle{
public static void main(String[] args){
final double PI = 3.14159;
int radius;
Scanner scan = new Scanner(System.in);
System.out.print ("Please enter the a radius ");
radius = scan.nextInt();
double area = PI * radius * radius;
System.out.println("The area of a circle with radius " + radius +
" is " + area);
System.out.print ("Please enter the a radius ");
radius = scan.nextInt();
area = PI * radius * radius;
System.out.println("The area of a circle with radius " + radius +
" is " + area);
}

Did you write this code? If so, then you already know how to add statements to do more stuff, since that's what you did to write this in the first place.
Do you know how to calculate circurmference?

Similar Messages

  • What is wrong with this program it keeps telling me the file doesn't exist?

    this program is supposed to write the file so why does it need the file to already exist?
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.ArrayList;
    import java.util.Scanner;
    public class NewClass implements ActionListener{
        static List list = new List();
        static TextField input = new TextField(20);
        static Button submit = new Button("Submit");
        static Frame f = new Frame("RealmList editor");
        static File file = new File("/Applications/World of Warcraft/realmlist.wtf");
        static Label status = new Label("");
        static Button selected = new Button("Change to Selected");
        static File config = new File("/Applications/RealmLister/config.txt");
        static File dir = new File("/Applications/RealmLister/");
        public static void main(String[] args) {
            f.setLayout(new BorderLayout());
            f.add(list, BorderLayout.CENTER);
            Panel p = new Panel();
            p.add(input);
            p.add(submit);
            p.add(selected);
            f.add(p, BorderLayout.NORTH);
            f.add(status, BorderLayout.SOUTH);
            new NewClass();
            f.setSize(500,500);
            f.setVisible(true);
            try {
                loadConfig();
            } catch(Exception e) {}
            f.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent we) {
                    try {
                      writeConfig();
                      System.exit(0);
                    } catch(Exception e) {
                       status.setText("Error: config couldn't be written!("+e+")");
        public NewClass() {
            submit.addActionListener(this);
            input.addKeyListener(new KeyAdapter() {
                public void keyPressed(KeyEvent e) {
                    if(e.getKeyCode() == KeyEvent.VK_ENTER) {
                    try {
                    editRealmlist(input.getText(), true);
                    input.setText("");
                 catch(Exception ex) {
                   status.setText("Error: "+e);
            selected.addActionListener(this);
        public void actionPerformed(ActionEvent e) {
            if(e.getSource() == submit) {
                try {
                    editRealmlist(input.getText(), true);
                    input.setText("");
                } catch(Exception ex) {
                   status.setText("Error: "+e);
                   wait(3000);
                   status.setText("");
            if(e.getSource() == selected) {
                try {
                    editRealmlist(list.getSelectedItem(),false);
                } catch(Exception ex) {
                    status.setText("Error: "+e);
                    wait(3000);
                    status.setText("");
        public static void loadConfig() throws Exception{
            if(config.exists()) {
                Scanner scan = new Scanner(config);
                ArrayList<String> al = new ArrayList<String>();
                while(scan.hasNext()) {
                    al.add(scan.nextLine());
                for(int i = 0; i < al.size(); i++) {
                    list.add(al.get(i));
        public static void writeConfig() throws Exception{
            FileWriter fw = new FileWriter(config);
            dir.mkdir();
            config.mkdirs();
            String temp = "";
            for(int i = 0; i < list.getItemCount(); i++) {
                temp += list.getItem(i)+"\n";
            fw.write(temp);
            fw.flush();
            System.gc();
        public static void editRealmlist(String realm, boolean addtoList) throws Exception{
            FileWriter fw = new FileWriter(file);
            fw.write("set realmlist "+realm+"\nset patchlist us.version.worldofwarcraft.com");
            fw.flush();
            status.setText("Editing RealmList.wtf Please Wait...");
            Thread.sleep(3000);
            status.setText("");
            System.gc();
            if(addtoList)
                list.add(realm);
        public void wait(int time) {
            try {
                Thread.sleep(time);
            catch(Exception e) {}
    }

    Erm, you should call mkdirs() on a File object that represents a directory.

  • When I type my email address in the "To:" field, a random name comes up next to it as "Holidays in United States". This just started happening out of the blue and I have no idea why. Does anyone else have any idea?

    When I type my email address in the "To:" field, a random name comes up next to it as "Holidays in United States". This just started happening out of the blue and I have no idea why. Does anyone else have any idea?

    Just to recap, this is a collection of ports I have collected over time for people who needed this information when setting up the HP ePrint app so that they could view their email from within the app.  I am certain other applications also need this information.  Although lengthy, I could not find a more comprehensive place to retrieve this information.  Feel free to post additional information, faulty information, or other related topics below as this is simply a collection of data and it would be practically impossible to test all of them. Thank you!
    Don't forgot to say thanks by giving "Kudos" if I helped solve your problem.
    When a solution is found please mark the post that solves your issue.
    Every problem has a solution!

  • TS2446 I can't buy on hay day game he told me contact iTunes support to complete this transaction after that told me the billing server not respond try again later and the other game same but I can buy games from the AppStore ? Please help me

    I can't buy on hay day game he told me contact iTunes support to complete this transaction after that told me the billing server not respond try again later and the other game same but I can buy games from the AppStore ?

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • HT1414 My iphone backup is stored on a computer I no longer have access to. Is there another way I can access this backup without that particular computer?

    My iphone backup is stored on a computer I no longer have access to. Is there another way I can access this backup without that particular computer?

    You don't have iCloud set up?   There would be a backup there if you enabled it.

  • I am trying to activate my program into my new computer (the old one was run over by a car) and it says I have exceeded my installations.  It's Adobe Audition 3 (you can see I've been using it a long time) and I rely on it for work everyday.  Please advis

    I am trying to activate my program into my new computer (the old one was run over by a car) and it says I have exceeded my installations.  It's Adobe Audition 3 (you can see I've been using it a long time) and I rely on it for work everyday.  Please advise.

    The activation server for Audition 3 was shut down by Adobe several years ago.
    You now need to download the non-activation version provided by Adobe here
    Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3
    Install then enter the new serial number provided by Adobe at that link. Your existing serial number will no longer work.

  • How do I stop firefox from sending a message or note that " do I want this program to change my computer?" It changes some of the settings in my computer; like the color of my task bar changed and other settings too.

    Before nothing happened until just recently when box messages would appear and tell me to click "yes or no" if I want the program to change my laptop. I clicked "No", but sometimes it didn't work, and when it didn't work. When it failed, fire fox changed some of the settings in my laptop. For example, the task bar's color would be changed. Also, it seemed as if fire fox had changed some of the settings into an old version. Yesterday I restarted my laptop, and it just went back to normal like nothing happened. But, for a few minutes later, the box will appear and you have to click yes or no. I clicked the "x" button, and it just changed automatically.

    Check that you do not run Firefox as Administrator.<br />
    Right-click the Firefox desktop shortcut and choose "Properties".<br />
    In the Compatibility tab, make sure that Privilege Level: "Run this program as Administrator" is not selected.<br />
    You also need to check the Properties of the firefox.exe program in the Firefox program directory.<br />

  • How do i add a countdown timer in as3 that starts when the program begins?

    I also want it to remove everything that is on the stage when it reaches 0 and produce a Game Over screen.

    import flash.events.TimerEvent;
    import flash.utils.Timer;
    var countdown:Timer = new Timer (1000,TARGET_TIME);
    //after 60 Seconds every DisplayObject will be removed from stage
    const TARGET_TIME:int = 60;
    countdown.addEventListener(TimerEvent.TIMER, tick);
    countdown.addEventListener(TimerEvent.TIMER_COMPLETE, gameOver);
    function tick(e:TimerEvent):void {
        //this will count upwards 1.2.3.4....
        trace(e.currentTarget.currentCount);
    function gameOver(e:TimerEvent):void {
        // this function will remove all DisplayObjects from your Stage
        // starting from the top
        //It will not remove shapes or anything the user might have drawn on the stage
        //just things that are accessible to ActionScript (Sprites, MovieClips)
        for (var i:int = this.numChildren-1 ; i >= 0; i--) {
            removeChildAt(i);
    //countdown will start only if you call it explicitly
    countdown.start();

  • Lately when I launch Firefox an alert window comes up asking of I want this program to make changes to the computer. Also, I am unable to download PDF files from other sites.

    This Problem started about two weeks ago.

    Check that you do not run Firefox as Administrator.
    Right-click the Firefox desktop shortcut and choose "Properties".
    Make sure that all items are deselected in the "Compatibility" tab of the Properties window.
    * Privilege Level: "Run this program as Administrator" should not be selected
    * "Run this program in compatibility mode for:" should not be selected
    Also check the Properties of the firefox.exe program in the Firefox program directory.

  • Why this program don't work without the "stop"?

    can you tell me why this program don't work without "stop"?and why the "stop" of my program can not work?
    Attachments:
    N(%}QA2R@SOLAF_12~0SQ)A.jpg ‏67 KB

    Crossrulz, sometimes you can snip the URL of the image:
    http://forums.ni.com/ni/attachments/ni/170/823066/1/
    The stop button is checked once in every iteration of the while loop, which includes waiting for the for loop to complete its 9 iteration.
    The for loop takes 9 seconds to complete because of the time delay, therefore clicking the stop button can take upto 18 seconds, depending on whether the button has been read yet.
    Turn on the highlight execution )light bulb icon) to see what is happening in your code
    - Cheers, Ed

  • How could i add actions to this program....

    i am trying to add action events so that the menuItems will do something when selected (with if else statements) such as changing the background color or font text
    yes, i am very new to java
    thanks for any help
    here is what i'm working with
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ThemeChanger extends JFrame
    JTextArea output;
    JScrollPane scrollPane;
    public ThemeChanger()
    JMenuBar menuBar;
    JMenu menu;
    JMenuItem blue;
    JMenuItem red;
    JMenuItem green;
    addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    // Add components to window
    Container contentPane = getContentPane();
    output = new JTextArea(5, 20);
    output.setEditable(false);
    scrollPane = new JScrollPane(output);
    contentPane.add(scrollPane, BorderLayout.CENTER);
    //Create the menu bar.
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    //Build the first menu.
    menu = new JMenu("Themes");
    menuBar.add(menu);
    //a group of JMenuItems
    blue = new JMenuItem("Blue");
    menu.add(blue);
    red = new JMenuItem("Red");
    menu.add(red);
    green = new JMenuItem("Green");
    menu.add(green);
    public static void main(String args[])
    ThemeChanger window = new ThemeChanger();
    window.setTitle("Theme Changer");
    window.setSize(300, 300);
    window.setVisible(true);

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ThemeChanger extends JFrame implements ActionListener{
       JMenuItem blue;
       JMenuItem red;
       JMenuItem green;
       JMenuItem coorier = new JMenuItem("Courier");
       JMenuItem times = new JMenuItem("Times new Roman");
       JMenuItem tahomah = new JMenuItem("Tahoma");;
       JMenuItem comics = new JMenuItem("Verdana");;  
       JMenu mFont;
       JTextArea output;
       JComboBox fontSizes;
       boolean newFont;
       String fontChanged = "Arial";
       int mySize = 12;
       Font startFont = new Font(fontChanged, Font.PLAIN,mySize);
      public ThemeChanger(){
         JMenu menu;
         Container contentPane = getContentPane();
         output = new JTextArea(4, 12);
         output.setFont(startFont);
         JScrollPane scrollPane = new JScrollPane(output);
         contentPane.add(scrollPane, BorderLayout.CENTER);
         JMenuBar menuBar = new JMenuBar();
         setJMenuBar(menuBar);
         menu = new JMenu("Colour");
         menuBar.add(menu);
         blue = new JMenuItem("Blue");
         blue.addActionListener(this);
         menu.add(blue);
         red = new JMenuItem("Red");
         menu.add(red);
         red.addActionListener(this);
         green = new JMenuItem("Green");
         green.addActionListener(this);
         menu.add(green);
         mFont= new JMenu("Font");
          mFont.add(coorier);
          coorier.addActionListener(this);
          mFont.add(times);
          times.addActionListener(this);
          mFont.add(tahomah);
          tahomah.addActionListener(this);
          mFont.add(comics);
          comics.addActionListener(this);
          menuBar.add(mFont);
          mFont.addActionListener(this);
         fontSizes = new JComboBox();
          fontSizes.addItem("Size");
          fontSizes.addItem("8");
          fontSizes.addItem("10");
          fontSizes.addItem("11");
          fontSizes.addItem("12"); 
          fontSizes.addItem("14");
          fontSizes.addItem("18");
          fontSizes.addItem("22");
          fontSizes.addItem("28");
          fontSizes.addItem("36");
          fontSizes.addItem("48");
          fontSizes.addItem("72");
            fontSizes.setMaximumRowCount(5);
          fontSizes.setBackground(Color.white);
          fontSizes.addActionListener(this);
         menuBar.add(fontSizes);
      public void actionPerformed(ActionEvent e){
        if(e.getSource()==blue)  output.setForeground(Color.blue);
        if(e.getSource()==red)   output.setForeground(Color.red);
        if(e.getSource()==green) output.setForeground(Color.green);
        if(e.getSource()==fontSizes) {
           mySize = Integer.parseInt((String)fontSizes.getSelectedItem());
           output.setFont(new Font(fontChanged, Font.PLAIN,mySize));
        if(((e.getSource()==coorier))||((e.getSource()==times)||(e.getSource()==tahomah))||((e.getSource()==comics))) {
           fontChanged = e.getActionCommand();
           output.setFont(new Font(fontChanged, Font.PLAIN,mySize));
      public static void main(String args[]) {
         ThemeChanger window = new ThemeChanger();
         window.setTitle("Theme Changer");
         window.setSize(300, 300);
         window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         window.setVisible(true);
    }

  • Continued "Trial" and "License this program" issue on "new" computer...

    I downloaded Adobe Acrobat XI Pro on my new computer from the Files on my old Computer. I do not have access to my old computer anymore. The 'Help' on my new computer is showing 'Deactivation' as a 'gray' option. I have a serial number (registered on the Adobe site) that when entered (Since it keeps telling me this is a trial version) tells me to contact Customer Support. On the Registration Page on Adobe it states this number is Registered to Adobe 9 (yet Adobe XI Pro was working on my old computer). I have no problem downloading Adobe 9 on my new computer...if it will work, but cannot find the files for download (and do not have my old computer...which only had Adobe Acrobat XI Pro). Suggestions? Just want my Adobe Acrobat Pro to work again...Thanks in advance for any assistance...

    uninstall acrobat xi and clean, Download Adobe Reader and Acrobat Cleaner Tool - Adobe Labs
    then reinstall the version of acrobat for which you have a serial number.
    Downloads available:
    Suites and Programs:  CC | CS6 | CS5.5 | CS5 | CS4 | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  12 | 11, 10 | 9, 8, 7
    Photoshop Elements:  12 | 11, 10 | 9,8,7
    Lightroom:  5 | 4 | 3
    Captivate:  7 | 6 | 5
    Contribute:  CS5 | CS4, CS3
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

  • I am sick and tired of Firefox crashing from Adobe Flash player. All support statements say to reinstall and that doesnt solve the problem!

    I am sick and tired of your Firefox not supporting Adobe Flash player. Windows explorer no problem it works fine. All of your support statements tell me to reinstall and I've tried that more than once and nothing improves! It is slowing up my computer, and I have a windows folder with 4.8Mb of auto generated crash messages!

    If you have problems with current Shockwave Flash plugin versions then check this:
    * see if there are updates for your graphics drive drivers
    '''https://support.mozilla.org/kb/upgrade-graphics-drivers-use-hardware-acceleration'''
    * disable protected mode in the Flash plugin (Flash 11.3+ on Windows Vista and later)
    '''https://forums.adobe.com/message/4468493#TemporaryWorkaround'''
    * disable hardware acceleration in the Flash plugin
    '''https://forums.adobe.com/thread/891337'''
    See also:
    * '''http://kb.mozillazine.org/Flash#Troubleshooting'''

  • I just downloaded ADE on a new computer.  I had this program on my old computer and had a library.  How do I get the library to download to this computer?

    I just downloaded ADE on a new computer.  I had ADE on my old computer with a library.  How do I get my library to download to the new computer?

    Engadget has a guide for this.
    http://www.engadget.com/2009/11/25/how-to-get-music-videos-and-photos-off-your-i pod-iphone/

  • I bought my Macbook pro on June 19, but the up to date program says that my computer is over the 30 days. What now?

    I've tried very hard to get the new X OS Lion, but I can't get the download to work. Now what do I do?

    Did you purchase your Mac from the Apple store? Try this click on your Apple menu then select about this Mac, when the window opens copy the serial number by selecting it then clicking the edit menu item then select copy, go bac to your browser and paste the number into the box then try it. 

Maybe you are looking for